# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
415808 | snasibov05 | Jousting tournament (IOI12_tournament) | C++14 | 1097 ms | 4444 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <vector>
using namespace std;
#define pb push_back
vector<int> val;
vector<vector<int>> ed;
int buildTree(int n, int c, int*& s, int*& e){
int idx = n;
vector<int> cur;
for (int i = 0; i < n; ++i) {
cur.pb(i);
}
for (int i = 0; i < c; ++i) {
for (int j = s[i]; j <= e[i]; ++j){
ed[idx].pb(cur[j]);
}
vector<int> arr;
for (int j = 0; j < s[i]; ++j) {
arr.pb(cur[j]);
}
arr.pb(idx);
for (int j = e[i]+1; j < cur.size(); ++j) {
arr.pb(cur[j]);
}
cur = arr;
idx++;
}
return idx-1;
}
void dfs(int v){
for (auto x : ed[v]){
dfs(x);
val[v] = max(val[v], val[x]);
}
}
int GetBestPosition(int n, int c, int r, int *k, int *s, int *e) {
val.resize(2*n);
ed.resize(2*n);
int m = buildTree(n, c, s, e);
int mx = 0, ans = 0;
for (int i = 0; i < n; ++i) {
val.assign(2*n+1, 0);
for (int j = 0; j < i; ++j) {
val[j] = k[j];
}
val[i] = r;
for (int j = i; j < n-1; ++j) {
val[j+1] = k[j];
}
dfs(m);
int cnt = 0;
for (int j = 0; j <= m; ++j) {
if (val[j] == r) cnt++;
}
if (cnt > mx) {
ans = i;
mx = cnt;
}
}
return ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |