Submission #1012959

#TimeUsernameProblemLanguageResultExecution timeMemory
1012959HappyCapybaraArranging Shoes (IOI19_shoes)C++17
10 / 100
1 ms348 KiB
#include "shoes.h" #include<bits/stdc++.h> using namespace std; #define ll long long ll count_swaps(vector<int> s){ int n = s.size()/2; map<int,queue<int>> m; for (int i=0; i<2*n; i++) m[s[i]].push(i); ll res = 0; int x = 0; vector<bool> done(2*n, false); for (int i=0; i<2*n; i++){ if (done[i]){ x--; continue; } int j = m[-s[i]].front(); m[-s[i]].pop(); res += j-i; if (s[i] < 0) res--; done[i] = true; done[j] = true; x++; } 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...