# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
151169 | imyujin | On the Grid (FXCUP4_grid) | C++17 | 18 ms | 380 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 "grid.h"
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1005;
int chk[MAXN];
vector<int> SortDisks(int N) {
vector<int> v, ans;
ans.resize(N);
for(int i = 0; i < N; i++) v.push_back(i);
for(int i = 0; i < N; i++) chk[i] = -1;
int X = PutDisks(v);
while(!v.empty()) {
vector<int> w;
int t = v.back();
for(int i = v.size() - 1; i > 0; i--) v[i] = v[i - 1];
v[0] = t;
int p = 0;
for(int i = 0; i < N; i++) {
if(chk[i] != -1) w.push_back(chk[i]);
else w.push_back(v[p++]);
}
int Y = PutDisks(w);
if(Y >= X) {
t = v[0];
ans[t] = Y;
for(int i = N - 1; w[i] != v[0]; i--) ans[t]--;
chk[ans[t] - 1] = t;
for(int i = 0; i < v.size() - 1; i++) v[i] = v[i + 1];
v.pop_back();
}
else X = Y;
}
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... |