Submission #153780

#TimeUsernameProblemLanguageResultExecution timeMemory
153780asifthegreatArranging Shoes (IOI19_shoes)C++14
65 / 100
1079 ms3192 KiB
#include <bits/stdc++.h> using namespace std; #include "shoes.h" const int N = 300000; long long count_swaps(std::vector<int> s) { int n = s.size(); if(true){ int papa = n/2; bool ok = true; for(int i = 0; i < papa;i++){ if(s[i] == -s[i+papa] and s[i] < 0)continue; ok = false;break; } if(ok){ long long nn = (int)s.size()/2ll; return nn*(nn-1ll)/2ll; } } int cnt = 0; for(int i = 0; i < n;i+=2){ int k = -69; for(int j = i+1; j < n;j++){ if(s[i] == -s[j]){k = j;break;} } // printf("for %d, we found %d\n",i,k); while(k != i+1){ swap(s[k],s[k-1]); k--; cnt++; } if(s[i] > 0){ swap(s[i],s[i+1]);cnt++; } } return cnt; }
#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...