Submission #583287

#TimeUsernameProblemLanguageResultExecution timeMemory
583287JomnoiJousting tournament (IOI12_tournament)C++17
17 / 100
1090 ms1868 KiB
#include <bits/stdc++.h> using namespace std; int GetBestPosition(int N, int C, int R, int *K, int *S, int *E) { int max_win = -1, best_pos = 0; for(int p = 0; p < N; p++) { vector <pair <int, int>> order, tmp; int j = 0; for(int i = 0; i < p; i++) { order.emplace_back(K[j++], i); } order.emplace_back(R, p); while(j < N - 1) { order.emplace_back(K[j++], j + 1); } int cnt_win = 0; for(int c = 0; c < C; c++) { int op = 0; for(int i = S[c]; i <= E[c]; i++) { op = max(op, order[i].first); } tmp.clear(); for(int i = 0; i < S[c]; i++) { tmp.push_back(order[i]); } for(int i = S[c]; i <= E[c]; i++) { if(op == order[i].first) { if(order[i].second == p) { cnt_win++; } tmp.push_back(order[i]); } } for(int i = E[c] + 1; i < order.size(); i++) { tmp.push_back(order[i]); } order = tmp; } if(max_win < cnt_win) { max_win = cnt_win; best_pos = p; } } return best_pos; }

Compilation message (stderr)

tournament.cpp: In function 'int GetBestPosition(int, int, int, int*, int*, int*)':
tournament.cpp:14:35: warning: operation on 'j' may be undefined [-Wsequence-point]
   14 |             order.emplace_back(K[j++], j + 1);
      |                                  ~^~
tournament.cpp:14:35: warning: operation on 'j' may be undefined [-Wsequence-point]
tournament.cpp:36:37: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |             for(int i = E[c] + 1; i < order.size(); i++) {
      |                                   ~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...