제출 #790835

#제출 시각아이디문제언어결과실행 시간메모리
790835fatemetmhrAncient Books (IOI17_books)C++17
0 / 100
1 ms340 KiB
// ~ Be Name Khoda ~ // #include "books.h" #include <bits/stdc++.h> //#pragma GCC optimize ("O3") //#pragma GCC target("avx2") //#pragma GCC optimize("unroll-loops,Ofast") using namespace std; typedef long long ll; #define pb push_back #define mp make_pair #define all(x) x.begin(), x.end() #define fi first #define se second const int maxn = 1e6 + 10; const int maxn5 = 1e6 + 10; const int maxnt = 1.2e6 + 10; const int maxn3 = 1e3 + 10; const int mod = 1e9 + 7; const ll inf = 1e18; ll ans = 0; int per[maxn5]; int num = 0, av[maxn5], cnt = 0; bool mark[maxn5], f[maxn5]; void dfs(int v){ mark[v] = true; for(int i = min(v, per[v]); i < max(v, per[v]); i++) f[i] = true; ans += abs(v - per[v]); if(!mark[per[v]]) dfs(per[v]); } long long minimum_walk(std::vector<int> p, int s) { int n = p.size(); for(int i = 0; i < n; i++) per[i] = p[i]; fill(av, av + n + 5, n + 10); int mx = 0; for(int i = 0; i < n; i++) if(!mark[i]){ cnt = 0; dfs(i); num++; } int emp = 0; for(int i = 0; i < n - 1; i++) if(!f[i]) emp++; return ans + 2 * emp; }

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

books.cpp: In function 'long long int minimum_walk(std::vector<int>, int)':
books.cpp:46:6: warning: unused variable 'mx' [-Wunused-variable]
   46 |  int mx = 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...