Submission #297966

#TimeUsernameProblemLanguageResultExecution timeMemory
297966AutoratchAncient Books (IOI17_books)C++14
0 / 100
2 ms640 KiB
#include "books.h" #include <bits/stdc++.h> using namespace std; #define pii pair<int,tuple<int,int,int> > const int N = 2000; int n; map<int,vector<int> > ma; map<vector<int>,int> mb; int res[N][5][5]; priority_queue<pii,vector<pii>,greater<pii> > q; bool visited[N][5][5]; long long minimum_walk(std::vector<int> p, int s) { n = 4; vector<int> v; for(int i = 0;i < n;i++) v.push_back(i); int cnt = 0; for(int i = 0;i <= 4;i++) for(int j = 0;j <= 4;j++) for(int k = 0;k <= 4;k++) for(int l = 0;l <= 4;l++) { vector<int> v = {i,j,k,l}; ma[cnt] = v; mb[v] = cnt; cnt++; } for(int i = 0;i < N;i++) for(int j = 0;j <= n;j++) for(int k = 0;k <= n;k++) res[i][j][k] = INT_MAX; res[mb[p]][s][4] = 0; q.push({0,{mb[p],s,4}}); while(!q.empty()) { auto [per,id,hn] = q.top().second; q.pop(); if(visited[per][id][hn]) continue; visited[per][id][hn] = true; vector<int> now = ma[per]; for(int i = 0;i < 4;i++) if(res[per][id][hn]+abs(id-i)<res[per][i][hn]) { res[per][i][hn] = res[per][id][hn]+abs(id-i); q.push({res[per][i][hn],{per,i,hn}}); } vector<int> nx = now; int hnd = nx[id]; nx[id] = hn; if(res[per][id][hn]<res[mb[nx]][id][hnd]) { res[mb[nx]][id][hnd] = res[per][id][hn]; q.push({res[mb[nx]][id][hnd],{mb[nx],id,hnd}}); } } return res[mb[{0,1,2,3}]][0][4]; }

Compilation message (stderr)

books.cpp: In function 'long long int minimum_walk(std::vector<int>, int)':
books.cpp:33:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   33 |         auto [per,id,hn] = q.top().second;
      |              ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...