제출 #147277

#제출 시각아이디문제언어결과실행 시간메모리
147277joylintpArranging Shoes (IOI19_shoes)C++14
50 / 100
1071 ms3220 KiB
#include<bits/stdc++.h> #include "shoes.h" using namespace std; long long count_swaps(vector<int> s) { long long n = s.size(), ret = 0; for (int i = 0; i < n; i++) { if (i % 2 == 0) { int j; for (j = i; s[j] != -abs(s[i]); j++); ret += j - i; int t = s[j]; for (int k = j - 1; k >= i; k--) s[k + 1] = s[k]; s[i] = t; } else { int j; for (j = i; s[j] != -s[i - 1]; j++); ret += j - i; int t = s[j]; for (int k = j - 1; k >= i; k--) s[k + 1] = s[k]; s[i] = t; } /*for (int i : s) cerr << setw(2) << i << ' '; cerr << '\n';*/ } return ret; }
#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...