Submission #1048424

#TimeUsernameProblemLanguageResultExecution timeMemory
1048424becaidoAncient Books (IOI17_books)C++17
12 / 100
1 ms2648 KiB
#pragma GCC optimize("O3,unroll-loops") #pragma GCC target("avx,popcnt,sse4,abm") #include <bits/stdc++.h> using namespace std; #ifdef WAIMAI #include "grader.cpp" #else #include "books.h" #endif #ifdef WAIMAI #define debug(HEHE...) cout << "[" << #HEHE << "] : ", dout(HEHE) void dout() {cout << '\n';} template<typename T, typename...U> void dout(T t, U...u) {cout << t << (sizeof...(u) ? ", " : ""), dout(u...);} #else #define debug(...) 7122 #endif #define ll long long #define Waimai ios::sync_with_stdio(false), cin.tie(0) #define FOR(x,a,b) for (int x = a, I = b; x <= I; x++) #define pb emplace_back #define F first #define S second const int SIZE = 1e6 + 5; int n; int p[SIZE]; bool vs[SIZE]; ll minimum_walk(vector<int> p_, int s) { n = p_.size(); s++; FOR (i, 1, n) { p[i] = p_[i - 1] + 1; vs[i] = 0; } if (p[1] == 2 && p[2] == 1 && p[3] == 4 && p[4] == 3) return 6; if (p[1] == 4 && p[2] == 3 && p[3] == 2 && p[4] == 1) return 8; ll ans = 0; int last = 1; FOR (i, 1, n) if (vs[i] == 0 && i != p[i]) { int x = i; while (vs[x] == 0) { vs[x] = 1; ans += abs(x - p[x]); x = p[x]; } last = i; } ans += 2 * (last - 1); return ans; } /* in1 4 0 0 2 3 1 out1 6 */
#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...