Submission #1011673

#TimeUsernameProblemLanguageResultExecution timeMemory
1011673u_suck_oArranging Shoes (IOI19_shoes)C++17
0 / 100
0 ms344 KiB
#include "bits/stdc++.h" #include "shoes.h" using namespace std; long long count_swaps(vector<int> s) { long long ans = 0; long long n = s.size()/2; int p1 = 1, p2 = 1; for (int i = 0; i < 2*n; i++) { p1 = max(i+1, p1); p2 = max(i+1, p2); if (i % 2 == 0) { if (s[i] < 0) continue; while (s[p1] > 0) p1++; swap(s[i], s[p1]); ans += p1 - i; } if (i % 2 == 1) { if (s[i] > 1) continue; while (s[p2] < 0) p2++; swap(s[i], s[p2]); ans += p2 - i; } } return ans; }
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...