Submission #1048373

#TimeUsernameProblemLanguageResultExecution timeMemory
1048373becaidoAncient Books (IOI17_books)C++17
0 / 100
1 ms2396 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; } 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...