제출 #292759

#제출 시각아이디문제언어결과실행 시간메모리
292759SaboonAncient Books (IOI17_books)C++17
50 / 100
226 ms15992 KiB
#include "books.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; const int maxn = 1e6 + 10; bool visited[maxn]; long long minimum_walk(vector<int> p, int s){ int n = p.size(); set<int> S; ll answer = 0; for (int i = 0; i < n; i++) answer += abs(p[i]-i); int tmp = 0, Max = 0; for (int i = 0; i < n; i++){ if (!visited[i] and p[i] != i){ if (i >= Max) tmp += (i - Max); int x = i; while (!visited[x]){ visited[x] = 1; Max = max(Max, x); x = p[x]; } } } answer += 2*tmp; return answer; }

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

books.cpp: In function 'long long int minimum_walk(std::vector<int>, int)':
books.cpp:13:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   13 |     for (int i = 0; i < n; i++)
      |     ^~~
books.cpp:15:2: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   15 |  int tmp = 0, Max = 0;
      |  ^~~
#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...