제출 #1301832

#제출 시각아이디문제언어결과실행 시간메모리
1301832tuncay_pashaArranging Shoes (IOI19_shoes)C++20
10 / 100
1 ms408 KiB
#include "shoes.h" #include "bits/stdc++.h" using namespace std; long long count_swaps(vector<int> s) { int n = s.size(); vector<int> v; int lf = -abs(s[1]), rg = abs(s[1]); for (int i = 0; i < n; ++i) { v.push_back(lf); v.push_back(rg); } int ans = 0; for (int i = 0; i < n * 2 - 1; ++i) { if (s[i] == v[i]) continue; int idx = -1; for (int j = i + 1; j < n * 2; ++j) { if (s[j] == v[i]) { idx = j; break; } } for (int j = idx - 1; j >= i; --j) { ++ans; swap(s[j], s[j + 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...