제출 #1177766

#제출 시각아이디문제언어결과실행 시간메모리
1177766alwaus424Arranging Shoes (IOI19_shoes)C++17
10 / 100
1 ms328 KiB
#include <bits/stdc++.h> using namespace std; int64_t count_swaps(vector<int> S) { int64_t swaps = 0; int n = S.size(); for(int i = 0;i<n*2;i++){ if(i % 2 == 0 && S[i] > 0 ){ int nex1 = 0; for(int j = i+1;j<2*n;j++){ if(S[j] == -1){ nex1 = j; break; } } while(nex1 > i) { swap(S[nex1] , S[nex1-1]); nex1--; swaps++; } } else if(i & 1 && S[i] < 0){ int nex1 = 0; for(int j = i+1;j<2*n;j++){ if(S[j] == 1){ nex1 = j; break; } } while(nex1 > i) { swap(S[nex1] , S[nex1-1]); nex1--; swaps++; } } } return swaps; }
#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...