제출 #1080693

#제출 시각아이디문제언어결과실행 시간메모리
1080693andrei_iorgulescu고대 책들 (IOI17_books)C++14
0 / 100
1 ms4700 KiB
#include <bits/stdc++.h> #include "books.h" #warning That's not FB, that's my FB using namespace std; using ll = long long; int n, s; int p[1000005], pos[1000005]; vector<vector<int>> cyc; vector<int> cur; bool viz[1000005]; void dfs(int nod) { viz[nod] = true; cur.push_back(nod); if (!viz[p[nod]]) dfs(p[nod]); } ll minimum_walk(vector<int> PERM, int STR) { cyc.clear(); memset(viz,0,sizeof(viz)); n = PERM.size(); for (int i = 1; i <= n; i++) p[i] = PERM[i - 1] + 1, pos[p[i]] = i; s = STR; for (int i = 1; i <= n; i++) { if (!viz[i]) { cur.clear(); dfs(i); cyc.push_back(cur); } } ll ans = 0; for (auto it : cyc) if (it.size() != 1) ans = max(ans, 2ll * (it[0] - 2)); for (auto it : cyc) { if (it.size() == 1) continue; for (int i = 0; i + 1 < it.size(); i++) ans += abs(it[i] - it[i + 1]); ans += abs(it.back() - it[0]); } return ans; }

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

books.cpp:3:2: warning: #warning That's not FB, that's my FB [-Wcpp]
    3 | #warning That's not FB, that's my FB
      |  ^~~~~~~
books.cpp: In function 'll minimum_walk(std::vector<int>, int)':
books.cpp:48:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   48 |         for (int i = 0; i + 1 < it.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...