Submission #788088

#TimeUsernameProblemLanguageResultExecution timeMemory
788088aykhnArranging Shoes (IOI19_shoes)C++14
50 / 100
1081 ms4292 KiB
#include <bits/stdc++.h> #include "shoes.h" // author: aykhn using namespace std; typedef long long ll; #define TC int t; cin >> t; while (t--) _(); #define OPT ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define all(v) v.begin(), v.end() #define pii pair<int, int> #define mpr make_pair #define eb emplace_back #define new int32_t #define pb push_back #define ts to_string #define fi first #define se second #define ins insert #define inf 0x3F3F3F3F #define infll 0x3F3F3F3F3F3F3F3FLL #define bpc __builtin_popcount long long count_swaps(vector<int> V) { vector<int> v; int n = V.size(); v.pb(0); for (int i = 0; i < n; i++) v.pb(V[i]); ll ans = 0; for (int i = 1; i <= n; i += 2) { int ind = -1; for (int j = i + 1; j <= n; j++) { if (v[j] == -v[i]) { ind = j; break; } } for (int k = ind - 1; k >= i + 1; k--) { ans++; swap(v[k], v[k + 1]); } if (v[i] > 0) { swap(v[i], v[i + 1]); ans++; } } 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...