Submission #556121

#TimeUsernameProblemLanguageResultExecution timeMemory
556121Trisanu_DasArranging Shoes (IOI19_shoes)C++17
65 / 100
1084 ms3108 KiB
#include "shoes.h" #include <bits/stdc++.h> using namespace std; #define ll long long ll 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; }
#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...