Submission #147275

#TimeUsernameProblemLanguageResultExecution timeMemory
147275joylintpArranging Shoes (IOI19_shoes)C++14
10 / 100
1086 ms3192 KiB
#include<bits/stdc++.h> #include "shoes.h" using namespace std; long long count_swaps(vector<int> s) { long long n = s.size(), ret = 0; for (int i = 0; i < n; i++) { if (i % 2 == 0) { int j; for (j = i; s[j] > 0; j++); ret += j - i; int t = s[j]; for (int k = j - 1; k >= i; k--) s[k + 1] = s[k]; s[i] = t; } else { int j; for (j = i; s[j] != -s[i - 1]; j++); ret += j - i; int t = s[j]; for (int k = j - 1; k >= i; k--) s[k + 1] = s[k]; s[i] = t; } /*for (int i : s) cerr << setw(2) << i << ' '; cerr << '\n';*/ } return ret; }
#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...