Submission #294638

#TimeUsernameProblemLanguageResultExecution timeMemory
294638mode149256Arranging Shoes (IOI19_shoes)C++14
10 / 100
1085 ms2304 KiB
#include<bits/stdc++.h> #include "shoes.h" using namespace std; using ll = long long; using vi = vector<int>; using vl = vector<ll>; ll count_swaps(vi s) { ll ats = 0; int N = (int)s.size(); for (int i = 0; i < N; ++i) { if (s[i] > 0) { int nx = i + 1; while (s[nx] > 0) nx++; int val = s[nx]; s.erase(s.begin() + nx); s.insert(s.begin() + i, val); ats += nx - i; } assert(s[i] < 0); // s[i] < 0 int nx = i + 1; while (-s[i] != s[nx]) nx++; ats += nx - (i + 1); s.erase(s.begin() + nx); s.insert(s.begin() + i + 1, -s[i]); i++; } return ats; }
#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...