Submission #156293

#TimeUsernameProblemLanguageResultExecution timeMemory
156293NucleistAncient Books (IOI17_books)C++14
12 / 100
2063 ms1048580 KiB
#include <bits/stdc++.h> using namespace std; #define flash ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0) #define debug(x) cerr << " - " << #x << ": " << x << endl; #define debugs(x, y) cerr << " - " << #x << ": " << x << " " << #y << ": " << y << endl; #define all(x) (x).begin(),(x).end() #define sz(x) (ll)x.size() #define ll long long #define INF 1000000000 #define pb push_back #define ve vector<ll> #define dos pair<ll,ll> #define vedos vector<dos> #define rand mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()) struct greateri { template<class T> bool operator()(T const &a, T const &b) const { return a > b; } }; vector<int>ans1; map<pair<int,pair<int,vector<int>>>,int>gg; ll minimum_walk(vector<int> p,int s) { for (int i = 0; i < p.size(); ++i) { ans1.pb(i); } priority_queue<pair<pair<int,int>,pair<int,vector<int>>>>ga; ga.push({{0,s},{-1,p}}); while(!ga.empty()) { auto yo = ga.top(); if(yo.second.second==ans1 && yo.first.second==0) { return abs(yo.first.first); } ga.pop(); if(yo.first.second!=0 && gg.find({yo.first.second-1,{yo.second.first,yo.second.second}})==gg.end()) { gg[{yo.first.second-1,{yo.second.first,yo.second.second}}]=1; ga.push({{yo.first.first-1,yo.first.second-1},{yo.second.first,yo.second.second}}); } if(yo.first.second!=(p.size()-1) && gg.find({yo.first.second+1,{yo.second.first,yo.second.second}})==gg.end()) { gg[{yo.first.second+1,{yo.second.first,yo.second.second}}]=1; ga.push({{yo.first.first-1,yo.first.second+1},{yo.second.first,yo.second.second}}); } int next = yo.second.second[yo.first.second]; auto zo = yo; swap(zo.second.first,zo.second.second[zo.first.second]); if(gg.find({zo.first.second,{zo.second.first,zo.second.second}})==gg.end()) { gg[{zo.first.second,{zo.second.first,zo.second.second}}]=1; ga.push({{zo.first.first,zo.first.second},{zo.second.first,zo.second.second}}); } } } //code the AC sol ! // BS/queue/map

Compilation message (stderr)

books.cpp: In function 'long long int minimum_walk(std::vector<int>, int)':
books.cpp:24:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 0; i < p.size(); ++i)
                  ~~^~~~~~~~~~
books.cpp:43:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if(yo.first.second!=(p.size()-1) && gg.find({yo.first.second+1,{yo.second.first,yo.second.second}})==gg.end())
      ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
books.cpp:48:7: warning: unused variable 'next' [-Wunused-variable]
   int next  = yo.second.second[yo.first.second];
       ^~~~
books.cpp:57:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
#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...