結果
問題 | No.43 野球の試合 |
ユーザー | satanic |
提出日時 | 2016-03-22 20:16:54 |
言語 | C++11 (gcc 11.4.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,582 bytes |
コンパイル時間 | 638 ms |
コンパイル使用メモリ | 70,792 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-01 13:05:37 |
合計ジャッジ時間 | 1,122 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 2 ms
5,248 KB |
testcase_02 | AC | 2 ms
5,248 KB |
testcase_03 | AC | 1 ms
5,248 KB |
testcase_04 | AC | 1 ms
5,248 KB |
testcase_05 | AC | 1 ms
5,248 KB |
testcase_06 | WA | - |
testcase_07 | AC | 1 ms
5,248 KB |
testcase_08 | AC | 0 ms
5,248 KB |
testcase_09 | AC | 1 ms
5,248 KB |
testcase_10 | WA | - |
ソースコード
#include <iostream> #include <vector> #include <algorithm> /* #define SHOWMTRX(a){printf("---"#a"---\n");for(int i=0;i<n;++i){for(int j=0;j<n;++j){printf("%4d",a[i][j]);}printf("\n");}printf("----\n");} #define SHOWARRY(a){printf("---"#a"---\n");for(int i=0;i<n;++i){printf("%4d\n",a[i]);}printf("----\n");} */ int main() { //std::ios::sync_with_stdio(false); //std::cin.tie(0); int n; std::cin >> n; std::vector<std::vector<int>> s(n, std::vector<int>(n)); std::vector<std::vector<int>> evaluation(n, std::vector<int>(n)); std::vector<int> point(n, 0); for (int i = 0; i < n; ++i) { for (int j = 0; j < n; ++j) { char c; std::cin >> c; switch (c) { case '#': s[i][j] = 99; break; case 'o': s[i][j] = 1; break; case 'x': s[i][j] = -1; break; case '-': s[i][j] = 0; break; } } }//SHOWMTRX(s); for (int i = 0; i < n; ++i) { if (s[0][i] == 0) { s[0][i] = 1; s[i][0] = -1; } }//SHOWMTRX(s); for (int i = 0; i < n; ++i) { int sum = 0; for (int j = 0; j < n; ++j) { if (s[i][j] == 99) continue; sum += s[i][j]; } point[i] = sum; }//SHOWARRY(point); for (int i = 0; i < n; ++i) { for (int j = 0; j < n; ++j) { if (s[i][j] != 0) evaluation[i][j] = -99; else evaluation[i][j] = point[i]; } }//SHOWMTRX(evaluation); for (int i = 0; i < n; ++i) { for (int j = i + 1; j < n; ++j) { if (evaluation[i][j] == -99) continue; int tmp = evaluation[j][i]; evaluation[j][i] -= evaluation[i][j]; evaluation[i][j] -= tmp; evaluation[i][j] *= -1; evaluation[j][i] *= -1; } }//SHOWMTRX(evaluation); bool flag; do { flag = false; int max = -99, maxI, maxJ; for (int i = 0; i < n; ++i) { for (int j = 0; j < n; ++j) { if (max < evaluation[i][j]) { max = evaluation[i][j]; maxI = i; maxJ = j; flag = true; } } } if (flag) { evaluation[maxI][maxJ] = -99; evaluation[maxJ][maxI] = -99; s[maxI][maxJ] = 1; s[maxJ][maxI] = -1; } } while (flag); //SHOWMTRX(s); for (int i = 0; i < n; ++i) { int sum = 0; for (int j = 0; j < n; ++j) { if (s[i][j] == 99) continue; sum += s[i][j]; } point[i] = sum; }//SHOWARRY(point); int pointZero = point[0]; std::sort(point.begin(), point.end()); std::reverse(point.begin(), point.end()); std::vector<int> rank; for (int i = 0; i < n; ++i) { if (std::find(rank.begin(), rank.end(), point[i]) == rank.end()) { rank.push_back(point[i]); } } for (int i = 0; i < rank.size(); ++i) { if (rank[i] == pointZero) { std::cout << i + 1 << "\n"; break; } } return 0; }