Submission #131128

#TimeUsernameProblemLanguageResultExecution timeMemory
131128claudyAncient Books (IOI17_books)C++14
0 / 100
2049 ms376 KiB
# include "books.h" # pragma GCC optimize("Ofast") # pragma GCC optimization ("unroll-loops") # include "bits/stdc++.h" /* # include <ext/pb_ds/tree_policy.hpp> # include <ext/pb_ds/assoc_container.hpp> # include <ext/rope> */ std::pair<int,int> DR[] = {{-1,0},{0,1},{1,0},{0,-1},{-1,1},{-1,-1},{1,1},{1,-1}}; # define ll long long # define clock (clock() * 1000.0 / CLOCKS_PER_SEC) # define rc(s) return cout << s,0 # define rcg(s) cout << s;exit(0) # define _ ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0); # define db(x) cerr << #x << " = " << x << '\n' # define pb push_back # define mp make_pair # define all(s) s.begin(),s.end() # define sz(x) (int)((x).size()) //# define int ll using namespace std; /* using namespace __gnu_pbds; using namespace __gnu_cxx; template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>; Tree<int>tr; */ int aux,x,pos,curr; ll minimum_walk(vector<int>p, int s) { int n = sz(p); vector<int>vec; for(int i = 0;i < n;i++) { vec.pb(i); } int ans = 1e9; vector<int>aux; do { aux = p; x = 0; pos = 0; curr = -1; for(auto it : vec) { int idx = -1; for(int i = 0;i < sz(aux);i++) { if(aux[i] == it) idx = i; } if(idx != -1) { x += abs(idx - pos); pos = idx; aux[pos] = curr; curr = it; } x += abs(pos - it); curr = aux[it]; aux[it] = it; pos = it; } ans = min(ans,x + pos); }while(next_permutation(vec.begin(),vec.end())); return ans; }

Compilation message (stderr)

books.cpp:3:0: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
 # pragma GCC optimization ("unroll-loops")
#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...