求球赛AC代码

看了半天看不出错误,真的niupi
全部评论
同看不出错误。。。  只过了40%  心好累啊  。。。
点赞 回复 分享
发布于 2017-09-16 17:15
#include "iostream" #include "vector" #include "algorithm" #include "unordered_set" #include "set" #include "unordered_map" #include "cstdio" #include "queue" #include "algorithm" #include "climits" #include "map" #include "stack" #include "cstring" #include "climits" using namespace std; #define ll long long #define mod 1000000007 struct score{     int s;     int v;     int l;     string name;     score(string s):name(s),s(0),v(0),l(0){} }; void getName(string s,string& a,string& b){     int i=0;     while(s[i]!='-')i++;     a=s.substr(0,i);     b=s.substr(i+1,s.length()-i-1); } void getS(string s,int& a,int& b){     int i=0;     while(s[i]!=':')i++;     a=0;b=0;     for(int j=0;j<i;j++)a=10*a+s[j]-'0';     for(int j=i+1;j<s.length();j++)b=10*b+s[j]-'0'; } bool cmp(score* a,score* b){     if(a->s>b->s)return true;     if(a->s<b->s)return false;     if((a->v-a->l)>(b->v-b->l))return true;     if((a->v-a->l)<(b->v-b->l))return false;     return (a->v)>(b->v); } int main(){     int n;     while(cin>>n){         unordered_map<string,int> map;         vector<score*> a(n);         int i;         string name;         for(i=0;i<n;i++){             cin>>name;             a[i]=new score(name);             map[name]=i;         }         int L=n*(n-1)/2;         string p,q;         string name1,name2;         int s1,s2;         for(i=0;i<L;i++){             cin>>p>>q;             getName(p,name1,name2);             getS(q,s1,s2);             //cout<<name1<<" "<<name2<<endl;             int id1=map[name1];             int id2=map[name2];             a[id1]->v+=s1;             a[id2]->v+=s2;             a[id1]->l+=s2;             a[id2]->l+=s1;             if(s1>s2){                 a[id1]->s+=3;             }else if(s1==s2){                 a[id1]->s+=1;                 a[id2]->s+=1;             }else{                 a[id2]->s+=3;             }         }         sort(a.begin(),a.end(),cmp);         for(int i=0;i<n;i++){             //cout<<a[i]->name<<" "<<a[i]->s<<" "<<a[i]->v<<" "<<a[i]->l<<endl;         }         n/=2;         vector<string> result(n);         for(int i=0;i<n;i++){             result[i]=a[i]->name;         }         sort(result.begin(),result.end());         for(int i=0;i<n;i++){             cout<<result[i]<<endl;         }     }     return 0; } 40%...
点赞 回复 分享
发布于 2017-09-16 17:19
球赛真的不知道哪里出了问题,名字按字母序也考虑了,一直30%,另外两题倒还是挺**的基本一遍过(除了有一次把没冲突要输出YES直接忽略了之外.........)
点赞 回复 分享
发布于 2017-09-16 17:21

相关推荐

点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务