제출 #312476

#제출 시각아이디문제언어결과실행 시간메모리
312476NaynaArranging Shoes (IOI19_shoes)C++14
10 / 100
1 ms512 KiB
#include "shoes.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]); idx--; cnt++; } ans+=cnt; used[idx] = 1; used[idx+1] = 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...