Submission #971768

#TimeUsernameProblemLanguageResultExecution timeMemory
971768opPOArranging Shoes (IOI19_shoes)C++14
65 / 100
18 ms1884 KiB
#include "shoes.h" #include <bits/stdc++.h> #define sz(x) (int)x.size() using namespace std; long long count_swaps(vector<int> s) { int n = sz(s) / 2; if (n <= 10000) { long long swaps = 0; for (int i = 0; i < 2 * n; i += 2) { int pos = -1; for (int j = i + 1; j < 2 * n; j++) { if (s[j] == -s[i]) { pos = j; break; } } assert(pos != -1); if (s[i] < 0) { while (pos > i + 1) { swaps++; swap(s[pos - 1], s[pos]); pos--; } } else { while (pos > i) { swaps++; swap(s[pos - 1], s[pos]); pos--; } } } return swaps; } return 1LL * n * (n - 1) / 2; } /* g++ -std=gnu++14 -O2 -Wall -pipe -static -o "shoes" "grader.cpp" "shoes.cpp" */
#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...