科大讯飞 球赛 0%过
感觉把所有都考虑了,包括积分相同考虑净胜球,净胜球数相同考虑总进球数
但是,实在不懂为什么一直是0%,贴上代码
#include <iostream> #include <string> #include <vector> #include <map> #include <utility> #include <algorithm> using namespace std; int n; vector<string> clubs; vector<pair<string, vector<int>> > newclubs; // vector jf p-n p map<string, vector<int>> cnts; bool Cmp(pair<string, vector<int>> mp1, pair<string, vector<int>> mp2) { if (mp1.second[0] > mp2.second[0]) return true; if (mp1.second[0] == mp2.second[0]) { if (mp1.second[1] > mp2.second[1]) return true; if (mp1.second[1] == mp2.second[1]) if (mp1.second[2] > mp2.second[2]) return true; } return false; } void GetNewClub() { clubs.clear(); newclubs.clear(); cnts.clear(); cin >> n; clubs = vector<string>(n, ""); int i; string ab, a, b, xy; string x, y; char fg = '-'; char fg2 = ':'; for (i = 0; i < n; i++) { cin >> clubs[i]; cnts.insert(make_pair(clubs[i], vector<int>(3, 0))); } for (i = 0; i < n*(n-1)/2; i++) { cin >> ab >> xy; int posi = ab.find(fg); a = ab.substr(0, posi); b = ab.substr(posi+1); int posi2 = xy.find(fg2); x = xy.substr(0, posi2); y = xy.substr(posi2+1); if (x > y) { cnts[a][0] += 3; cnts[a][1] += atoi(x.c_str())-atoi(y.c_str()); cnts[a][2] += atoi(x.c_str()); cnts[b][1] += atoi(y.c_str())-atoi(x.c_str()); cnts[b][2] += atoi(y.c_str()); } else if (x < y) { cnts[a][1] += atoi(x.c_str())-atoi(y.c_str()); cnts[a][2] += atoi(x.c_str()); cnts[b][0] += 3; cnts[b][1] += atoi(y.c_str())-atoi(x.c_str()); cnts[b][2] += atoi(y.c_str()); } else { cnts[a][0] += 1; cnts[a][1] += atoi(x.c_str())-atoi(y.c_str()); cnts[a][2] += atoi(x.c_str()); cnts[b][0] += 1; cnts[b][1] += atoi(y.c_str())-atoi(x.c_str()); cnts[b][2] += atoi(y.c_str()); } } for (auto &a : cnts) newclubs.push_back(make_pair(a.first, a.second)); sort(newclubs.begin(), newclubs.end(), Cmp); clubs.clear(); for (i = 0; i < n/2; i++) clubs.push_back(newclubs[i].first); sort(clubs.begin(), clubs.end()); for (auto &a : clubs) cout << a << endl; return; } int main() { while (1) { GetNewClub(); } return 0; }