Submission #824916

#TimeUsernameProblemLanguageResultExecution timeMemory
824916kwongwengAncient Books (IOI17_books)C++17
50 / 100
121 ms20960 KiB
#include "books.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<int> vi; typedef pair<int, int> ii; typedef vector<ii> vii; typedef long double ld; typedef pair<ll, ll> pll; #define FOR(i, a, b) for(int i = a; i < b; i++) #define ROF(i, a, b) for(int i = a; i >= b; i--) #define ms memset #define pb push_back #define fi first #define se second ll minimum_walk(vi p, int s) { int n=p.size(); vi used(n); vii r; ll ans=0; FOR(i,0,n){ if (used[i] || p[i]==i) continue; int cur=i; int mx=0; while (p[cur] != i){ ans += abs(p[cur]-cur); mx=max(mx,cur); used[cur]=1; cur=p[cur]; } ans += abs(i-cur); mx=max(mx,cur); used[cur]=1; r.pb({i,mx}); } int mx=0; FOR(i,0,r.size()){ if (r[i].fi >= mx) ans += 2*(r[i].fi-mx); mx=max(mx,r[i].se); } return ans; }

Compilation message (stderr)

books.cpp: In function 'll minimum_walk(vi, int)':
books.cpp:10:39: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   10 | #define FOR(i, a, b) for(int i = a; i < b; i++)
......
   32 |  FOR(i,0,r.size()){
      |      ~~~~~~~~~~~~                      
books.cpp:32:2: note: in expansion of macro 'FOR'
   32 |  FOR(i,0,r.size()){
      |  ^~~
#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...