제출 #122071

#제출 시각아이디문제언어결과실행 시간메모리
122071nvmdava고대 책들 (IOI17_books)C++17
0 / 100
3 ms512 KiB
#include "books.h" #include <bits/stdc++.h> using namespace std; long long res; long long minimum_walk(std::vector<int> p, int s){ while(!p.empty() && p.back() == p.size() - 1) p.pop_back(); if(p.empty()) return 0; int n = p.size(); if(s >= n){ res += (s - n + 1) << 1; s = n - 1; } reverse(p.begin(), p.end()); s = n - 1 - s; for(int i = 0; i < n; i++) p[i] = n - 1 - p[i]; while(p.back() == p.size() - 1) p.pop_back(); n = p.size(); if(s >= n){ res += (s - n + 1) << 1; s = n - 1; } int tmn = s, tmx = s; for(int i = 0; i < n; i++){ res += abs(p[i] - i); if(1LL * (tmx - p[i]) * (tmx - i) <= 0 || 1LL * (tmn - p[i]) * (tmn - i) <= 0){ tmx = max(tmx, max(i, p[i])); tmn = min(tmn, min(i, p[i])); } } int l, r, mn, mx; l = mn = min(s, p[s]); r = mx = max(s, p[s]); while(mn != tmn || mx != tmx){ res += 2; mn--; mx++; while(l != mn || r != mx){ if(l != mn){ l--; mn = min(mn, p[l]); mx = max(mx, p[l]); } else { r++; mn = min(mn, p[r]); mx = max(mx, p[r]); } } } for(; l >= 0; l--){ if(mn > l) res += 2; mn = min(mn, p[l]); } for(; r < n; r++){ if(mx < r) res+= 2; mx = max(mx, p[r]); } return res; }

컴파일 시 표준 에러 (stderr) 메시지

books.cpp: In function 'long long int minimum_walk(std::vector<int>, int)':
books.cpp:6:33: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    while(!p.empty() && p.back() == p.size() - 1)
                        ~~~~~~~~~^~~~~~~~~~~~~~~
books.cpp:19:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    while(p.back() == p.size() - 1)
          ~~~~~~~~~^~~~~~~~~~~~~~~
#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...