제출 #247008

#제출 시각아이디문제언어결과실행 시간메모리
247008ernestvwArranging Shoes (IOI19_shoes)C++17
50 / 100
1093 ms22008 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; ll count_swaps(vector<int> S) { int n = (int)S.size(); ll ans = 0; vector<bool> prise(n, false); vector<set<int>> L(n+1), R(n+1); int i = 0; while(i < n) { if(S[i] < 0) { int j = -1; for(int k = i + 1; k < n; ++k) if(S[k] == -S[i]) { j = k; break; } for(int l = j; l > i + 1; --l) swap(S[l], S[l-1]), ++ans; } else { if(i > 0 && S[i-1] == -S[i]) { ++i; continue; } int j = -1; for(int k = i + 1; k < n; ++k) if(S[k] == -S[i]) { j = k; break; } for(int l = j; l > i; --l) swap(S[l], S[l-1]), ++ans; } i++; } 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...