제출 #256387

#제출 시각아이디문제언어결과실행 시간메모리
256387tincamatei마상시합 토너먼트 (IOI12_tournament)C++14
17 / 100
1092 ms2356 KiB
#include <bits/stdc++.h> int getWins(std::vector<int> knights, int C, int *S, int *E, int R) { int res = 0; for(int i = 0; i < C; ++i) { std::vector<int> newknights; int best = 0; for(int j = S[i]; j <= E[i]; ++j) best = std::max(best, knights[j]); for(int j = 0; j < S[i]; ++j) newknights.push_back(knights[j]); newknights.push_back(best); for(int j = E[i] + 1; j < knights.size(); ++j) newknights.push_back(knights[j]); knights = newknights; if(best == R) ++res; } return res; } int GetBestPosition(int N, int C, int R, int *K, int *S, int *E) { std::vector<int> knights; knights.push_back(R); for(int i = 0; i < N - 1; ++i) knights.push_back(K[i]); int bestpos = 0, res = getWins(knights, C, S, E, R); for(int P = 1; P < N; ++P) { std::swap(knights[P], knights[P - 1]); int res2 = getWins(knights, C, S, E, R); if(res2 > res) { res = res2; bestpos = P; } } return bestpos; }

컴파일 시 표준 에러 (stderr) 메시지

tournament.cpp: In function 'int getWins(std::vector<int>, int, int*, int*, int)':
tournament.cpp:14:29: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int j = E[i] + 1; j < knights.size(); ++j)
                           ~~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...