Submission #532202

#TimeUsernameProblemLanguageResultExecution timeMemory
532202devariaotaArranging Shoes (IOI19_shoes)C++17
65 / 100
1020 ms3096 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; ll count_swaps(vector<int>v){ ll n = v.size(); bool st4 = true; ll ans = 0; for(ll i = 0; i < n/2; i++){ if(v[i] != -v[n/2 + i] || v[i] > 0){ st4 = false; break; } } if(st4 && n > 2){ ll x = (n/2)*(n/2 - 1)/2; return x; } for(ll i = 0; i < n; i++){ ll cur = v[i]; ll l = -1; for(ll j = i - 1; j >= 0; j--){ if(v[j] == -cur) l = j; } if(l != -1){ ans += (i - l - (v[i] > 0)); for(ll j = i; j > l; j--) swap(v[j], v[j - 1]); v[l] = v[l + 1] = 0; } } return ans; } // int main(){ // int n; cin >> n; // vector<int>arr(n); // for(int i = 0; i < n; i++) cin >> arr[i]; // cout << count_swaps(arr) << endl; // return 0; // }
#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...