#include #include #include #include #include #include #define FORT(i,a,b) for((i)=(a);(i)<=(b);(i)++) using namespace std; typedef pair< int, pair< int, pair< int, pair< int,int > > > > VP; typedef struct { int index,win,tie,lost,pts,dif,gpl,goals,left,right; string score,name; VP srt; } TYP; void putc(char c){ printf("%c",c); } string itos(int a) { char tmp[10] ; sprintf(tmp,"%d",a); string res=string(tmp); return res; } bool operator < (const TYP& a,const TYP& b) { return a.srt9) pd++; if (co>99) pd++; if (co>999) pd++; if (co>9999) pd++; pis(' ',poc-pd); cout << co; } vector VC; string MX[99][99]; map NMTOI; int indexspace,gplspace,winspace,tiespace,lostspace,ptsspace,maxname,maxscore; TYP prv; int i,j,k,l,M,N,pd,ii,jj; string s,t,r; int main() { while (cin >> N,N!=0) { VC.clear(); FORT(i,1,N) { FORT(j,1,N) { MX[i][j]=" "; } } FORT(i,1,N) { MX[i][i]=" X "; } VC.push_back(prv); maxname=0; indexspace=0; gplspace=0; winspace=0; tiespace=0; lostspace=0; ptsspace=0; maxscore=0; FORT(i,1,N) { prv.win=0; prv.lost=0; prv.tie=0; prv.left=0; prv.right=0; prv.goals=0; prv.gpl=0; prv.pts=0; cin >> s; prv.name=s; prv.index=i; VC.push_back(prv); NMTOI[s]=i; if ((int)s.size()>maxname) { maxname=s.size(); } } cin >> M; FORT(i,1,M) { cin >> s; cin >> t; cin >> t; cin >> r; VC[NMTOI[s]].gpl++; VC[NMTOI[s]].left+=(r[0]-48); VC[NMTOI[s]].right+=(r[2]-48); VC[NMTOI[t]].gpl++; VC[NMTOI[t]].left+=(r[2]-48); VC[NMTOI[t]].right+=(r[0]-48); if (r[0]>r[2]) { VC[NMTOI[s]].pts+=3; VC[NMTOI[s]].win++; VC[NMTOI[t]].pts+=0; VC[NMTOI[t]].lost++; } if (r[0]==r[2]) { VC[NMTOI[s]].pts+=1; VC[NMTOI[s]].tie++; VC[NMTOI[t]].pts+=1; VC[NMTOI[t]].tie++; } if (r[0]maxscore) maxscore=VC[i].score.size(); pd=0; if (VC[i].win>9) pd++; if (VC[i].win>99) pd++; if (VC[i].win>999) pd++; if (VC[i].win>9999) pd++; if (pd>winspace) winspace=pd; pd=0; if (VC[i].tie>9) pd++; if (VC[i].tie>99) pd++; if (VC[i].tie>999) pd++; if (VC[i].tie>9999) pd++; if (pd>tiespace) tiespace=pd; pd=0; if (VC[i].lost>9) pd++; if (VC[i].lost>99) pd++; if (VC[i].lost>999) pd++; if (VC[i].lost>9999) pd++; if (pd>lostspace) lostspace=pd; pd=0; if (VC[i].pts>9) pd++; if (VC[i].pts>99) pd++; if (VC[i].pts>999) pd++; if (VC[i].pts>9999) pd++; if (pd>ptsspace) ptsspace=pd; pd=0; if (VC[i].index>9) pd++; if (VC[i].index>99) pd++; if (VC[i].index>999) pd++; if (VC[i].index>9999) pd++; if (pd>indexspace) indexspace=pd; pd=0; if (VC[i].gpl>9) pd++; if (VC[i].gpl>99) pd++; if (VC[i].gpl>999) pd++; if (VC[i].gpl>9999) pd++; if (pd>gplspace) gplspace=pd; /* pd=0; if (VC[i].gpl>9) pd++; if (VC[i].gpl>99) pd++; if (VC[i].gpl>999) pd++; if (VC[i].gpl>9999) pd++; if (pd>gplspace) gplspace=pd;*/ VC[i].srt=make_pair(0-VC[i].pts , make_pair(0-VC[i].dif ,make_pair(0-VC[i].goals ,make_pair( 0-VC[i].win ,0-VC[i].index)))); } cout << "RESULTS:" << endl; /*1*/ putc('+');pis('-',maxname); putc('+');FORT(i,1,N) { pis('-',3); putc('+');}cout << endl; /*2*/ putc('|');pis(' ',maxname); putc('|'); FORT(i,1,N) { if (VC[i].name.size()>=1) { putc(VC[i].name[0]); } else putc(' '); if (VC[i].name.size()>=2) { putc(VC[i].name[1]); } else putc(' '); if (VC[i].name.size()>=3) { putc(VC[i].name[2]); } else putc(' '); putc('|'); } cout << endl; /*3*/ putc('+');pis('-',maxname); putc('+');FORT(i,1,N) { pis('-',3); putc('+');} cout << endl; /*x*/ FORT(i,1,N){ putc('|'); cout << VC[i].name; pis(' ',maxname-VC[i].name.size()); putc('|'); FORT(j,1,N) { cout << MX[i][j]; putc('|'); } cout << endl; putc('+');pis('-',maxname); putc('+');FORT(j,1,N) { pis('-',3); putc('+');}cout << endl; } /**/ cout << endl; sort(VC.begin()+1,VC.end()); cout << "STANDINGS:" << endl; cout << "----------" << endl; FORT(i,1,N) { lalign(i,indexspace); cout << ". " << VC[i].name; pis(' ',maxname-VC[i].name.size()); cout << " "; lalign(VC[i].gpl,gplspace); cout << " "; lalign(VC[i].win,winspace); cout << " "; lalign(VC[i].tie,tiespace); cout << " "; lalign(VC[i].lost,lostspace); // cout << " " << VC[i].score << " "; cout << " "; pis(' ',maxscore-VC[i].score.size()); cout << VC[i].score << " "; lalign(VC[i].pts,ptsspace); cout << endl; } cout << endl; } return 0; }