Submission #1204086

#TimeUsernameProblemLanguageResultExecution timeMemory
1204086tamyteArranging Shoes (IOI19_shoes)C++20
10 / 100
0 ms328 KiB
#include "shoes.h" #include <vector> #include <iostream> using namespace std; using ll = long long; /* 2 2 1 -1 -2 3 -2 2 2 -2 -2 2 */ long long count_swaps(std::vector<int> s) { ll res = 0; int N = s.size(); for (int i = 0; i < N; i += 2) { int want = -s[i]; for (int j = i + 1; j < N; ++j) { if (s[j] == want) { int k = j; // cerr << k << " = " << want << endl; while (s[k - 1] != -want) { swap(s[k - 1], s[k]); k--; res++; } if (s[k - 1] > s[k]) { swap(s[k - 1], s[k]); res++; } break; } } } /*for (auto& u : s) { cout << u << " "; } cout << endl;*/ return res; }
#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...