Submission #920941

#TimeUsernameProblemLanguageResultExecution timeMemory
920941salmonAncient Books (IOI17_books)C++14
0 / 100
1 ms1372 KiB
#include "books.h" #include <bits/stdc++.h> using namespace std; long long minimum_walk(vector<int> p, int s) { bool done[1100100]; int N = p.size(); int un = N; int soom = 0; /*while(un != 0){ if(start ) }*/ int big = 0; for(int i = 0; i < N; i++){ if(done[i]) continue; done[i] = true; big = i; int j = p[i]; soom += abs(j - i); while(j != i){ int temp = j; done[j] = true; j = p[j]; soom += abs(temp - j); } } return soom + 2 * big; }

Compilation message (stderr)

books.cpp: In function 'long long int minimum_walk(std::vector<int>, int)':
books.cpp:11:9: warning: unused variable 'un' [-Wunused-variable]
   11 |     int un = N;
      |         ^~
#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...