Submission #423667

#TimeUsernameProblemLanguageResultExecution timeMemory
423667Bill_00Ancient Books (IOI17_books)C++14
50 / 100
242 ms23772 KiB
#include "books.h" #include <bits/stdc++.h> #define ll long long using namespace std; ll p[1000005],ans,vis[1000005],mx; void dfs(ll node){ ans+=(abs(node-p[node])); vis[node]=1; mx=max(node,mx); if(vis[p[node]]) return; dfs(p[node]); } long long minimum_walk(std::vector<int> P, int s){ for(ll i=0;i<P.size();i++) p[i]=P[i]; for(ll i=0;i<P.size();i++){ if(vis[i]==0 && i!=p[i]){ if(i>mx){ ans+=((i-mx)*2); } dfs(i); } } return ans; }

Compilation message (stderr)

books.cpp: In function 'long long int minimum_walk(std::vector<int>, int)':
books.cpp:14:14: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |  for(ll i=0;i<P.size();i++) p[i]=P[i];
      |             ~^~~~~~~~~
books.cpp:15:14: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |  for(ll i=0;i<P.size();i++){
      |             ~^~~~~~~~~
#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...