Submission #289306

#TimeUsernameProblemLanguageResultExecution timeMemory
289306TouubsAncient Books (IOI17_books)C++17
50 / 100
156 ms8388 KiB
#include "books.h" #include <bits/stdc++.h> long long minimum_walk(std::vector<int> p, int s) { std::vector<bool> visited(p.size()); long long res = 0; int maxVis = 0; for (int i = 0; i < p.size() && p[i] == i && i < s; i++); for (int i = 0; i < p.size(); i++) { if (maxVis < i) res+=2; res += abs(p[i] - i); maxVis = std::max(maxVis, p[i]); } for (int i = p.size() - 1; i > s && p[i] == i ; i--, res-=2); return res; }

Compilation message (stderr)

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