이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define pb emplace_back
#define pii pair<int,int>
#define ff first
#define ss second
using namespace std;
#define debug(args...) kout("[ " + string(#args) + " ]", args)
void kout() { cerr << endl; }
template <class T, class ...U> void kout(T a, U ...b) { cerr << a << ' ',kout(b...); }
template <class T> void pary(T L, T R) { while (L != R) cerr << *L << " \n"[++L==R]; }
int solve(int id, int N, int C, int R, int *K, int *S, int *E) {
vector <int> now;
for (int i = 0; i+1 < N; i++) {
if (now.size() == id) now.pb(R);
now.pb(K[i]);
}
if (now.size() == id) now.pb(R);
vector <int> tmp;
int cnt = 0;
for (int i = 0; i < C; i++) {
pii mmax = pii(-1, -1);
bool flag = false;
for (int j = S[i]; j <= E[i]; j++) {
mmax = max(mmax, pii(now[j], j));
flag |= (now[j] == R);
}
if (mmax.ff == R) cnt++;
else if (flag) return cnt;
for (int j = 0; j < now.size(); j++)
if (j < S[i] || j > E[i] || j == mmax.ss)
tmp.pb(now[j]);
now = tmp; tmp.clear();
}
return cnt;
}
int GetBestPosition(int N, int C, int R, int *K, int *S, int *E) {
pii ans = pii(0, 0);
for (int i = 0; i < N; i++)
ans = max(ans, pii(solve(i, N, C, R, K, S, E), -i));
return -ans.ss;
}
컴파일 시 표준 에러 (stderr) 메시지
tournament.cpp: In function 'int solve(int, int, int, int, int*, int*, int*)':
tournament.cpp:15:20: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
15 | if (now.size() == id) now.pb(R);
| ~~~~~~~~~~~^~~~~
tournament.cpp:18:18: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
18 | if (now.size() == id) now.pb(R);
| ~~~~~~~~~~~^~~~~
tournament.cpp:30:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
30 | for (int j = 0; j < now.size(); j++)
| ~~^~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |