Submission #487993

#TimeUsernameProblemLanguageResultExecution timeMemory
487993ala2Arranging Shoes (IOI19_shoes)C++14
50 / 100
1099 ms3404 KiB
#include "shoes.h" #include <iostream> using namespace std; int b[1000100]; int a[1000100]; void shift(int l,int r) { for(int i=l;i<=r;i++) { b[i]=a[i]; } for(int i=l+1;i<=r;i++) { a[i]=b[i-1]; } a[l]=b[r]; } long long count_swaps(vector<int> s) { int n=s.size(); if(1010){ for(int i=0;i<n;i++) { a[i]=s[i]; } int mn=0; for(int i=0;i<n;i++) { if(a[i]>0) { int e=-1; for(int j=i+1;j<n;j++) { if(a[j]==-a[i]) { e=j; break; } } shift(i,e); mn+=e-i; i++; } if(a[i]<0) { int e=-1; for(int j=i+1;j<n;j++) { if(a[j]==-a[i]) { e=j; break; } } shift(i+1,e); mn+=e-i-1; i++; } } return mn; } else { int nn=n/2-1; return nn*(nn+1)/2; } }
#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...