Submission #312479

#TimeUsernameProblemLanguageResultExecution timeMemory
312479NaynaArranging Shoes (IOI19_shoes)C++14
50 / 100
1092 ms4600 KiB
#include "shoes.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; int used[100005]; long long count_swaps(vector<int> s) { int ans = 0; int n = s.size(); for(int i = 0; i < n; i++) { if(used[i]) continue; int idx = -1; for(int r = i+1; r < n; r++) { if(s[r]==(-1*s[i])) { idx = r; break; } } int cnt = 0; while(idx-1!=i) { swap(s[idx], s[idx-1]); idx--; cnt++; } if(s[idx]<s[idx-1]) { swap(s[idx], s[idx-1]); cnt++; } //cout << i << ' ' << idx << '\n'; //for(int j = 0; j < s.size(); j++) cout << s[j] << ' '; //cout << '\n'; ans+=cnt; used[i] = 1; used[idx] = 1; } return ans; }
#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...