Submission #775908

#TimeUsernameProblemLanguageResultExecution timeMemory
775908petezaAncient Books (IOI17_books)C++14
12 / 100
1 ms312 KiB
#include <bits/stdc++.h> #include "books.h" using namespace std; int qs[1000005]; long long minimum_walk(std::vector<int> p, int s) { int cur = 0, cv = 0; long long cans = 0; for(int i=0;i<p.size();i++) { qs[min(i, p[i])]++; qs[max(i, p[i])]--; } for(int i=0;i<p.size();i++) { if(qs[i] && !cv) cur = i; cv += qs[i]; //cout << qs[i] << ' '; cans += cv; } return cans + 2*cur; }

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:12:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   12 |     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...