Submission #151025

#TimeUsernameProblemLanguageResultExecution timeMemory
151025Alexa2001On the Grid (FXCUP4_grid)C++17
100 / 100
21 ms504 KiB
#include "grid.h" #include <bits/stdc++.h> using namespace std; vector<int> v, mn, val; int n, ep; void solve() { int last = PutDisks(v) - n; int i; while(1) { vector<int> last_v = v; int id = v[ep]; for(i=ep; i; --i) v[i] = v[i-1]; v[0] = id; int now = PutDisks(v) - n; if(!now) return; if(now > last - 1) { val[id] = now + 1; v = last_v; --ep; auto cmp = [&val](int x, int y) { assert(val[x] && val[y]); return val[x] < val[y]; }; sort(v.begin() + ep + 1, v.end(), cmp); // solve(); // break; } else last--, mn[id] = min(mn[id], now + 1); } } vector<int> SortDisks(int _n) { int i; n = _n; v.resize(n); val.resize(n); mn.resize(n, n); for(i=0; i<n; ++i) v[i] = i; ep = n-1; solve(); vector<int> ans(n); for(i=0; i<n; ++i) ans[v[i]] = i+1; return ans; }

Compilation message (stderr)

grid.cpp: In function 'void solve()':
grid.cpp:31:26: warning: capture of variable 'val' with non-automatic storage duration
             auto cmp = [&val](int x, int y)
                          ^~~
grid.cpp:6:20: note: 'std::vector<int> val' declared here
 vector<int> v, mn, val;
                    ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...