Yandex.Algorithm 2016 Qualification Round 题解(待补)

Orthography

给n个字符串,输出任意一个字符串,它与其他每个字符串最多相差1个字符

#include<bits/stdc++.h>
using namespace std;
#define For(i,n) for(int i=1;i<=n;i++)
#define Fork(i,k,n) for(int i=k;i<=n;i++)
#define Rep(i,n) for(int i=0;i<n;i++)
#define ForD(i,n) for(int i=n;i;i--)
#define ForkD(i,k,n) for(int i=n;i>=k;i--)
#define RepD(i,n) for(int i=n;i>=0;i--)
#define Forp(x) for(int p=Pre[x];p;p=Next[p])
#define Forpiter(x) for(int &p=iter[x];p;p=Next[p])  
#define Lson (o<<1)
#define Rson ((o<<1)+1)
#define MEM(a) memset(a,0,sizeof(a));
#define MEMI(a) memset(a,127,sizeof(a));
#define MEMi(a) memset(a,128,sizeof(a));
#define INF (2139062143)
#define F (100000007)
#define pb push_back
#define mp make_pair 
#define fi first
#define se second
#define vi vector<int> 
#define pi pair<int,int>
#define SI(a) ((a).size())
typedef long long ll;
typedef unsigned long long ull;
ll mul(ll a,ll b){return (a*b)%F;}
ll add(ll a,ll b){return (a+b)%F;}
ll sub(ll a,ll b){return (a-b+llabs(a-b)/F*F+F)%F;}
void upd(ll &a,ll b){a=(a%F+b%F)%F;}
int read()
{
    int x=0,f=1; char ch=getchar();
    while(!isdigit(ch)) {if (ch=='-') f=-1; ch=getchar();}
    while(isdigit(ch)) { x=x*10+ch-'0'; ch=getchar();}
    return x*f;
} 
int n;
string s[2000];
int main()
{
//  freopen("A.in","r",stdin);
//  freopen(".out","w",stdout);

    cin>>n;
    For(i,n) cin>>s[i];
    int len=s[1].length();
    For(i,n) {
        int flag=0;
        For(j,n) {
            flag=0;
            Rep(k,len) if (s[i][k]!=s[j][k]) flag++;
            if (flag>1) break;
        }
        if (flag>1) continue;
        else {
            cout<<s[i]<<endl; return 0;
        } 
    }


    return 0;
}

Voice AlertsOne of the most important features in Yandex.Navigator is the voice alert of the next manoeuvre: the application kindly warns the driver about a turn they must make some time in advance. So people don’t have to constantly check the screen.

In order for the driver to have time to hear the alert and take appropriate actions, the alert needs to be started beforehand. Of course, the alert should not start too early, because if there’s too much time between the alert and the actual place of manoeuvre, the driver can forget about it or just miss the turn.
For the sake of simplicity, we assume that all the alerts have the form “after X meters turn right”, where X is a positive integer for which a voice pronunciation is recorded (the real application can warn the driver about different kinds of manoeuvres, not only right turns). Could you develop an algorithm that can choose such alert that the application needs to start pronouncing the alert as late as possible, in order not to distract the driver unnecessarily?
Consider the detailed mathematical model of the problem. We assume that the driver moves along a straight line at a constant speed of V meters per second. There is a list of integers Xi: the distances in meters for which there exists a recorded voice pronunciation. Each Xi corresponds to a real number ti: the duration of a voice recording of number Xi in seconds. Additionally, you are given a real number Tphrase: the total time it takes to pronounce the fixed part of the alert, that is, the words “after” and “meters turn right”. You are required to find the minimal number D, the distance to the start of the manoeuvre, and also an index i such that, starting from the time at which the driver will be in D meters from the place of manoeuvre, while driving at a constant speed V in time ti + Tphrase, the driver would be exactly Xi meters before the actual place of the manoeuvre. The indices of Xi start from 1.

阅读理解题。。

#include<bits/stdc++.h>
using namespace std;
#define For(i,n) for(int i=1;i<=n;i++)
#define Fork(i,k,n) for(int i=k;i<=n;i++)
#define Rep(i,n) for(int i=0;i<n;i++)
#define ForD(i,n) for(int i=n;i;i--)
#define ForkD(i,k,n) for(int i=n;i>=k;i--)
#define RepD(i,n) for(int i=n;i>=0;i--)
#define Forp(x) for(int p=Pre[x];p;p=Next[p])
#define Forpiter(x) for(int &p=iter[x];p;p=Next[p])  
#define Lson (o<<1)
#define Rson ((o<<1)+1)
#define MEM(a) memset(a,0,sizeof(a));
#define MEMI(a) memset(a,127,sizeof(a));
#define MEMi(a) memset(a,128,sizeof(a));
#define INF (2139062143)
#define F (100000007)
#define pb push_back
#define mp make_pair 
#define fi first
#define se second
#define vi vector<int> 
#define pi pair<int,int>
#define SI(a) ((a).size())
typedef long long ll;
typedef unsigned long long ull;
ll mul(ll a,ll b){return (a*b)%F;}
ll add(ll a,ll b){return (a+b)%F;}
ll sub(ll a,ll b){return (a-b+llabs(a-b)/F*F+F)%F;}
void upd(ll &a,ll b){a=(a%F+b%F)%F;}
int read()
{
    int x=0,f=1; char ch=getchar();
    while(!isdigit(ch)) {if (ch=='-') f=-1; ch=getchar();}
    while(isdigit(ch)) { x=x*10+ch-'0'; ch=getchar();}
    return x*f;
} 
int main()
{
//  freopen("B.in","r",stdin);
//  freopen(".out","w",stdout);

    double v,T;
    cin>>v>>T; 
    int n=read();
    double ans;
    int p;
    For(i,n) {
        double x,t;
        cin>>x>>t;
//      cout<<x+v*(t+T)<<endl;
        if (i==1) {
            ans=x+v*(t+T); p=1;
        } else if (ans>x+v*(t+T)){

            ans=x+v*(t+T); p=i;
        }
    } 
    cout<<setiosflags(ios::fixed)<<setprecision(5); 
    cout<<ans<<' '<<p<<endl;

    return 0;
}

Table Tennis Tournament

The Minsk’s office held a table tennis tournament. N employees participated in the tournament. During the tournament, each of them played exactly one match against every other. The winner of each match received 2 points, and the loser got 1 point. There are no ties in table tennis. At the end of the tournament, the scores of each participant were summed up, and it turned out that all the participants scored different number of points. Roma, Sergei and Alex are interested whether it is likely that the result of the tournament will have such a property.
For convenience, enumerate the employees by integers from 1 to N. Suppose that probabilities pij are known: the employee with the number i will win the match against an employee j with probability pij. Find the probability that after all the N(N-1)/2 matches, all participants will have different number of points.

显然它们分别胜利0,1,2,..,n-1局
赢1局的只打赢赢0局的
赢2局的只打赢赢0,1局的
..etc

#include<bits/stdc++.h>
using namespace std;
#define For(i,n) for(int i=1;i<=n;i++)
#define Fork(i,k,n) for(int i=k;i<=n;i++)
#define Rep(i,n) for(int i=0;i<n;i++)
#define ForD(i,n) for(int i=n;i;i--)
#define ForkD(i,k,n) for(int i=n;i>=k;i--)
#define RepD(i,n) for(int i=n;i>=0;i--)
#define Forp(x) for(int p=Pre[x];p;p=Next[p])
#define Forpiter(x) for(int &p=iter[x];p;p=Next[p])  
#define Lson (o<<1)
#define Rson ((o<<1)+1)
#define MEM(a) memset(a,0,sizeof(a));
#define MEMI(a) memset(a,127,sizeof(a));
#define MEMi(a) memset(a,128,sizeof(a));
#define INF (2139062143)
#define F (100000007)
#define pb push_back
#define mp make_pair 
#define fi first
#define se second
#define vi vector<int> 
#define pi pair<int,int>
#define SI(a) ((a).size())
typedef long long ll;
typedef unsigned long long ull;
ll mul(ll a,ll b){return (a*b)%F;}
ll add(ll a,ll b){return (a+b)%F;}
ll sub(ll a,ll b){return (a-b+llabs(a-b)/F*F+F)%F;}
void upd(ll &a,ll b){a=(a%F+b%F)%F;}
int read()
{
    int x=0,f=1; char ch=getchar();
    while(!isdigit(ch)) {if (ch=='-') f=-1; ch=getchar();}
    while(isdigit(ch)) { x=x*10+ch-'0'; ch=getchar();}
    return x*f;
} 
#define MAXN (100)
double a[MAXN][MAXN];
int c[100];
int main()
{
//  freopen("C.in","r",stdin);
//  freopen(".out","w",stdout);

    int n=read();
    For(i,n) c[i]=i;
    For(i,n) For(j,n) cin>>a[i][j];
    double tot=0;
    do {
        double ans=1;
        For(i,n) Fork(j,i+1,n) {
            ans*=a[c[i]][c[j]];
        } 

        tot+=ans;
    } while (next_permutation(c+1,c+1+n));

    printf("%.10lf\n",tot);
    return 0;
}
Python网络爬虫与推荐算法新闻推荐平台:网络爬虫:通过Python实现新浪新闻的爬取,可爬取新闻页面上的标题、文本、图片、视频链接(保留排版) 推荐算法:权重衰减+标签推荐+区域推荐+热点推荐.zip项目工程资源经过严格测试可直接运行成功且功能正常的情况才上传,可轻松复刻,拿到资料包后可轻松复现出一样的项目,本人系统开发经验充足(全领域),有任何使用问题欢迎随时与我联系,我会及时为您解惑,提供帮助。 【资源内容】:包含完整源码+工程文件+说明(如有)等。答辩评审平均分达到96分,放心下载使用!可轻松复现,设计报告也可借鉴此项目,该资源内项目代码都经过测试运行成功,功能ok的情况下才上传的。 【提供帮助】:有任何使用问题欢迎随时与我联系,我会及时解答解惑,提供帮助 【附带帮助】:若还需要相关开发工具、学习资料等,我会提供帮助,提供资料,鼓励学习进步 【项目价值】:可用在相关项目设计中,皆可应用在项目、毕业设计、课程设计、期末/期中/大作业、工程实训、大创等学科竞赛比赛、初期项目立项、学习/练手等方面,可借鉴此优质项目实现复刻,设计报告也可借鉴此项目,也可基于此项目来扩展开发出更多功能 下载后请首先打开README文件(如有),项目工程可直接复现复刻,如果基础还行,也可在此程序基础上进行修改,以实现其它功能。供开源学习/技术交流/学习参考,勿用于商业用途。质量优质,放心下载使用。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值