Notice
Recent Posts
Recent Comments
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
Tags
- function
- 하이퍼 터미널
- Java
- android studio
- Get
- 점점변하는값
- solution
- application.mk
- 파일존재
- php
- PORTG
- array
- Avr
- 현재언어
- selectc
- mathemetica
- unalias
- Call
- 0x
- 월별 카운트
- Join
- Post
- mysql
- C++
- is_array
- cocos2d-x
- halliday
- 강좌
- SQL
- 단축키
Archives
- Today
- Total
코딩도사의 코드정리
soccer UVA 본문
#include <iostream> #include <string> #include <vector> #include <algorithm> #include <map> #include <limits> #include <ctime> #include <set> #include <cstdio> #include <cstdlib> #include <cstring> #include <fstream> using namespace std; #ifdef mycom ifstream fin("input"); #else #define fin cin #endif class team { public: int score; int wincounter; int goaldiff; int manygoal; int gamecounter; string teamname; //////////// int drawcounter; int losecounter; int sibalgoal; team() { score = 0; wincounter = 0; goaldiff = 0; manygoal = 0; gamecounter = 0; drawcounter=0; losecounter=0; sibalgoal=0; } bool operator<(const team& t) const { if(this->score == t.score) { if(this->wincounter == t.wincounter) { if(this->goaldiff == t.goaldiff) { if(this->manygoal == t.manygoal) { if(this->gamecounter == t.gamecounter) { char ateam[100]; char bteam[100]; strcpy(ateam, teamname.c_str()); strcpy(bteam, t.teamname.c_str()); for(int i=0; i<strlen(ateam); i++) ateam[i] = toupper(ateam[i]); for(int i=0; i<strlen(bteam); i++) bteam[i] = toupper(bteam[i]); string a = ateam; string b = bteam; return a > b; } else { return this->gamecounter > t.gamecounter; } } else { return this->manygoal < t.manygoal; } } else { return this->goaldiff < t.goaldiff; } } else { return this->wincounter < t.wincounter; } } else { return this->score < t.score; } } }; int main() { int N; fin >> N; fin.ignore(1024, '\n'); for(int n=1; n<=N; n++) { int T; string tonorname; char temptonorname[1024]; fin.getline(temptonorname, 1024); tonorname = temptonorname; fin >> T; fin.ignore(1024, '\n'); vector<team> teams; for(int j=1; j<=T; j++) { char temp[1024]; fin.getline(temp, 1024); team tempteam; tempteam.teamname = temp; teams.push_back(tempteam); } int G; fin >> G; fin.ignore(1024, '\n'); for(int g=1; g<=G; g++) { char temp[1024]; char* p; int Ascore, Bscore; string Aname; string Bname; fin.getline(temp, 1024); p = strtok(temp, "#"); Aname = p; p = strtok(0, "@"); Ascore = atoi(p); p = strtok(0, "#"); Bscore = atoi(p); p = strtok(0, "#"); Bname = p; for(vector<team>::iterator iter = teams.begin(); iter != teams.end(); ++iter) { if((*iter).teamname == Aname) { if(Ascore > Bscore) { iter->score += 3; iter->wincounter++; } else if(Ascore == Bscore) { iter->drawcounter++; iter->score += 1; } else iter->losecounter++; iter->sibalgoal += Bscore; iter->manygoal += Ascore; iter->gamecounter++; iter->goaldiff += Ascore - Bscore; } else if( (*iter).teamname == Bname) { if(Bscore > Ascore) { iter->score += 3; iter->wincounter++; } else if(Ascore == Bscore) { iter->score += 1; iter->drawcounter++; } else iter->losecounter++; iter->sibalgoal += Ascore; iter->manygoal += Bscore; iter->gamecounter++; iter->goaldiff += Bscore - Ascore; } } } sort(teams.rbegin(), teams.rend()); cout << tonorname << endl; for(int i = 0; i<teams.size(); i++) { printf("%d) %s %dp, %dg (%d-%d-%d), %dgd (%d-%d)\n", i+1, teams[i].teamname.c_str(), teams[i].score, teams[i].gamecounter, teams[i].wincounter, teams[i].drawcounter, teams[i].losecounter, teams[i].goaldiff, teams[i].manygoal, teams[i].sibalgoal); } if(n != N) cout << endl; } return 0; }
'컴퓨터 이야기 > C++' 카테고리의 다른 글
순열 (0) | 2011.01.07 |
---|---|
부분집합 (0) | 2011.01.07 |
Bridge (0) | 2011.01.05 |
Vito's Family (0) | 2011.01.02 |
Erdos Numbers (0) | 2011.01.01 |