제출 #49209

#제출 시각아이디문제언어결과실행 시간메모리
49209MatheusLealV고대 책들 (IOI17_books)C++17
0 / 100
3 ms812 KiB
#include "books.h" #include <bits/stdc++.h> #define N 1000005 using namespace std; typedef long long ll; int G[N], ok[N], cor, sz[N], C[N]; void dfs(int x) { if(ok[G[x]]) return; ok[G[x]] = 1; dfs(G[x]); } void co(int x) { if(C[G[x]]) return; C[G[x]] = cor, sz[cor] ++; co(G[x]); } ll minimum_walk(vector<int> p, int s) { ll ans = 0; for(int i = 0; i < p.size(); i++) G[i] = p[i], ans += abs(i - p[i]); for(int i = 0; i < p.size(); i++) { if(C[i]) continue; ++cor; C[i] = cor; sz[cor] = 1; co(i); } while(s >= 0) { dfs(s); int prox = -1, d = 2000000000; for(int i = 0; i < p.size(); i++) { if(ok[i] || sz[C[i]] <= 1) continue; if(abs(s - i) < d) { d = abs(s - i); prox = i; } } if(prox == -1) ans += s; else ans += d; s = prox; } return ans; }

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

books.cpp: In function 'll minimum_walk(std::vector<int>, int)':
books.cpp:31:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i = 0; i < p.size(); i++) G[i] = p[i], ans += abs(i - p[i]);
                 ~~^~~~~~~~~~
books.cpp:33:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i = 0; i < p.size(); i++)
                 ~~^~~~~~~~~~
books.cpp:52:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   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...