Submission #950482

#TimeUsernameProblemLanguageResultExecution timeMemory
950482qinArranging Shoes (IOI19_shoes)C++17
10 / 100
1049 ms3004 KiB
#include <bits/stdc++.h> #define fi first #define se second #define ssize(x) int(x.size()) #define pn printf("\n") #define all(x) x.begin(),x.end() #define rall(x) x.rbegin(),x.rend() #define vv vector using namespace std; typedef long long ll; typedef pair<int, int> pii; int inf = 2e09; ll infll = 2e18; int mod = 119<<23|1; ll count_swaps(vv<int> t){ int n = ssize(t)/2; ll result = 0; for(int i = 0; i < n<<1; i += 2){ int st = i+1; for(int j = i+1; j < n<<1; ++j) if(abs(t[j]) == abs(t[i])){ st = j; break; } if(t[i] < 0) for(int j = st-1; j > i; --j) swap(t[j+1], t[j]), ++result; else for(int j = st-1; j >= i; --j) swap(t[j+1], t[j]), ++result; } return result; } #ifdef LOCAL int main(){ int T = 1; for(++T; --T; ){ int n; scanf("%d", &n); vv<int> t(n<<1); for(int i = 0; i < n<<1; ++i) scanf("%d", &t[i]); ll result = count_swaps(t); printf("%lld\n", result); } return 0; } #endif
#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...