codeforces 126 div2
raiting掉了。。。
为什么除了B题其他题都这么长。。。。。
还有万恶的C题,暴力枚举的时候我竟然从9开始枚举。。。。哎。
C题是模拟题,我写的很烦,到了最后时刻才交,可惜啊,百密一疏。。。
最近CF阅读量好大啊。。。。
C
View Code
#include<cstdio> #include<cstring> #include<set> #include<string> #include<iostream> #include<cmath> #include<vector> #include<map> #include<time.h> #include<queue> #include<cstdlib> #include<algorithm> using namespace std; typedef __int64 lld; #define lson l,m,rt<<1 #define rson m+1,r,rt<<1|1 const int maxn = 100010; struct node{ char s[25]; int scored; int missed; int diff; int points; void print() { printf("name %s\n",s); printf("scored %d\n",scored); printf("missed %d\n",missed); printf("diff %d\n",diff); printf("points %d\n",points); puts(""); } }info[6],cop[6]; int cmp(node a,node b){ if(a.points!=b.points) return a.points>b.points; if(a.diff!=b.diff) return a.diff>b.diff; if(a.scored!=b.scored) return a.scored>b.scored; return strcmp(a.s,b.s)<0; } int main() { set<string> st; map<string,int> mp,name; map<string,int> point; char s1[50],s2[50]; int a,b,tot=0; for(int i=1;i<=4;i++) { info[i].scored=info[i].diff=info[i].missed=info[i].points=0; } for(int i=0;i<5;i++) { scanf("%s%s%d:%d",s1,s2,&a,&b); st.insert(s1); st.insert(s2); mp[s1]++;mp[s2]++; if(mp[s1]==1){ name[s1]=++tot; strcpy(info[tot].s,s1); } if(mp[s2]==1) { name[s2]=++tot; strcpy(info[tot].s,s2); } info[name[s1]].scored+=a;info[name[s1]].missed+=b; info[name[s2]].scored+=b;info[name[s2]].missed+=a; if(a>b) info[name[s1]].points+=3; else if(a<b) info[name[s2]].points+=3; else { info[name[s2]].points+=1; info[name[s1]].points+=1; } } int x=-1,y=-1;string op; for(set<string>::iterator it=st.begin();it!=st.end();it++) { if(!(*it=="BERLAND")&&mp[*it]==2){ op=*it;break; } } for(int i=1;i<=4;i++) cop[i]=info[i]; int ret=1000000;int diff[4]; for(int i=100;i>=0;i--) { for(int j=i-1;j>=0;j--) { for(int k=1;k<=4;k++) info[k]=cop[k]; info[name["BERLAND"]].points+=3; info[name["BERLAND"]].scored+=i;info[name["BERLAND"]].missed+=j; info[name[op]].scored+=j;info[name[op]].missed+=i; for(int k=1;k<=4;k++){ info[k].diff=info[k].scored-info[k].missed; } sort(info+1,info+5,cmp); if((strcmp(info[1].s,"BERLAND")==0 || strcmp(info[2].s,"BERLAND")==0 ) &&((i-j)<ret||(i-j==ret && j<y))) { x=i; y=j; ret=i-j; } } }//printf("ret=%d\n",ret); if(x==-1) printf("IMPOSSIBLE\n"); else printf("%d:%d\n",x,y); return 0; }