Submission #959444

#TimeUsernameProblemLanguageResultExecution timeMemory
959444NemanjaSo2005Arranging Shoes (IOI19_shoes)C++17
15 / 100
15 ms3160 KiB
#include "shoes.h" #include<bits/stdc++.h> #define ll long long using namespace std; const int maxn=2e5+5; ll N,niz[maxn]; ll res=0; int prvalev(){ for(int i=1;i<=N;i++) if(niz[i]<0) return i; } int parod(int x){ for(int i=1;i<=N;i++) if(niz[i]==-x) return i; } void zamena(int y,int x){ for(int i=y;i>x;i--){ res++; swap(niz[i],niz[i-1]); } } ll count_swaps(vector<int> s) { N=s.size(); N/=2; return N*(N-1)/2; for(int i=0;i<N;i++) niz[i+1]=s[i]; for(int i=1;i<=N;i+=2){ int pl=prvalev(); zamena(pl,i); int pd=parod(niz[i]); // cout<<pl<<" "<<pd<<endl; zamena(pd,i+1); niz[i]=niz[i+1]=0; } return res; }

Compilation message (stderr)

shoes.cpp: In function 'int prvalev()':
shoes.cpp:12:1: warning: control reaches end of non-void function [-Wreturn-type]
   12 | }
      | ^
shoes.cpp: In function 'int parod(int)':
shoes.cpp:17:1: warning: control reaches end of non-void function [-Wreturn-type]
   17 | }
      | ^
#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...