Submission #428063

#TimeUsernameProblemLanguageResultExecution timeMemory
428063inwbearAncient Books (IOI17_books)C++14
50 / 100
157 ms8132 KiB
#include "books.h" #include <bits/stdc++.h> using namespace std; set<pair<int,int> >ss; long long ans=0; long long minimum_walk(std::vector<int> p, int s) { int ed=0,rr=0,sw1=s,sw2=s; for(int i=0;i<p.size();i++) { if(p[i]!=i) { sw1=min(sw1,min(i,p[i])); sw2=max(sw2,max(i,p[i])); } } for(int i=0;i<p.size();i++) { ed=max(ed,p[i]); if(sw1==i)rr=0; if(sw2==i)ans+=rr*2; if(ed==i) { rr++; } ans+=abs(i-p[i]); } return ans; }

Compilation message (stderr)

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