Submission #912513

#TimeUsernameProblemLanguageResultExecution timeMemory
912513agusssArranging Shoes (IOI19_shoes)C++14
50 / 100
1075 ms3264 KiB
#include "vector" #include "stdio.h" #include "iostream" using namespace std; long long count_swaps(std::vector<int> s) { vector<bool> used(s.size(), false); long long cnt = 0; // cout << "size:" << s.size() << "\n"; for (int i = 0; i < (int)s.size(); i++) { int j; if (used[i]) { continue; } // cout << "to pair" << i << "\n"; int cnt_used = 0; for (j = i + 1; j < (int)s.size(); j++) { cnt_used += used[j]; if (s[j] == -s[i] and !used[j]) { used[j] = true; break; } } if (j < (int)s.size()) { // cout << i << ": " << s[i] << " , "<< j << ": " << s[j] << "\n"; long long distance = j - i - (s[i] < 0 ? 1 : 0) - cnt_used; cnt += distance; } } return cnt; } int mani() { int n; if (scanf("%d\n", &n)); vector<int> A(n << 1); for (int i = 0; i < n << 1; i++) { if (scanf("%d", &A[i])); } printf("%lld\n", count_swaps(A)); return 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...
#Verdict Execution timeMemoryGrader output
Fetching results...