Submission #532546

#TimeUsernameProblemLanguageResultExecution timeMemory
532546devariaotaArranging Shoes (IOI19_shoes)C++17
65 / 100
1095 ms3120 KiB
//#include "shoes.h" #include <bits/stdc++.h> using namespace std; #define ll long long long long count_swaps(std::vector<int> s) { ll n = s.size(); bool flag = true; ll ans = 0; for(ll i = 0; i < n/2; i++){ if(s[i] != -s[n/2 + i] || s[i] > 0){ flag = false; break; } } if(flag && n > 2){ ll x = (n/2)*(n/2 - 1)/2; return x; } for(ll i = 0; i < n; i++){ ll cur = s[i]; ll l = -1; for(ll j = i - 1; j >= 0; j--){ if(s[j] == -cur) l = j; } if(l != -1){ ans += (i - l - (s[i] > 0)); for(ll j = i; j > l; j--) swap(s[j], s[j - 1]); s[l] = s[l + 1] = 0; } } return ans; } /*int main(){ int n; scanf("%d",&n); vector<int>arr(n); for(int i=0;i<n;i++) scanf("%d",&arr[i]); printf("%d\n",count_swaps(arr)); 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...