Submission #143850

#TimeUsernameProblemLanguageResultExecution timeMemory
143850daniel920712Arranging Shoes (IOI19_shoes)C++14
10 / 100
33 ms3720 KiB
#include <iostream> #include <stdio.h> #include <vector> #include <algorithm> #include <assert.h> using namespace std; int S1[1005]; int S2[1005]; int all[1005]; int a[1005]={0}; int b[1005]={0}; bool F(int a,int b) { return a<b; } long long count_swaps(std::vector<int> S) { long long ans1=0,ans2=0,ans3=0,ans4=0,N=S.size(),now=0,x,y,small,what; long long t; int i,j,k; now=0; for(i=0;i<N/2;i++) { for(j=1;j<=N/2;j++) { a[j]=100000000; b[j]=100000000; } for(j=2*i;j<N;j++) { if(S[j]<0) b[0-S[j]]=min(b[0-S[j]],j); else a[S[j]]=min(a[S[j]],j); } small=1000000000; for(j=1;j<=N/2;j++) { if(a[j]+b[j]<=small) { small=a[j]+b[j]; if(a[j]<b[j]) small++; what=j; } } //printf("%lld\n",what); for(j=2*i;j<N;j++) { if(S[j]==0-what) { for(k=j;k>2*i;k--) { swap(S[k],S[k-1]); ans1++; } break; } } for(j=2*i+1;j<N;j++) { if(S[j]==what) { for(k=j;k>2*i+1;k--) { swap(S[k],S[k-1]); ans1++; } break; } } } return ans1; }

Compilation message (stderr)

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:19:22: warning: unused variable 'ans2' [-Wunused-variable]
     long long ans1=0,ans2=0,ans3=0,ans4=0,N=S.size(),now=0,x,y,small,what;
                      ^~~~
shoes.cpp:19:29: warning: unused variable 'ans3' [-Wunused-variable]
     long long ans1=0,ans2=0,ans3=0,ans4=0,N=S.size(),now=0,x,y,small,what;
                             ^~~~
shoes.cpp:19:36: warning: unused variable 'ans4' [-Wunused-variable]
     long long ans1=0,ans2=0,ans3=0,ans4=0,N=S.size(),now=0,x,y,small,what;
                                    ^~~~
shoes.cpp:19:54: warning: variable 'now' set but not used [-Wunused-but-set-variable]
     long long ans1=0,ans2=0,ans3=0,ans4=0,N=S.size(),now=0,x,y,small,what;
                                                      ^~~
shoes.cpp:19:60: warning: unused variable 'x' [-Wunused-variable]
     long long ans1=0,ans2=0,ans3=0,ans4=0,N=S.size(),now=0,x,y,small,what;
                                                            ^
shoes.cpp:19:62: warning: unused variable 'y' [-Wunused-variable]
     long long ans1=0,ans2=0,ans3=0,ans4=0,N=S.size(),now=0,x,y,small,what;
                                                              ^
shoes.cpp:20:15: warning: unused variable 't' [-Wunused-variable]
     long long t;
               ^
shoes.cpp:48:23: warning: 'what' may be used uninitialized in this function [-Wmaybe-uninitialized]
             if(S[j]==0-what)
                      ~^~~~~
#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...