Submission #151169

#TimeUsernameProblemLanguageResultExecution timeMemory
151169imyujinOn the Grid (FXCUP4_grid)C++17
100 / 100
18 ms380 KiB
#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)

grid.cpp: In function 'std::vector<int> SortDisks(int)':
grid.cpp:31:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for(int i = 0; i < v.size() - 1; i++) v[i] = v[i + 1];
                   ~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...