Submission #959438

#TimeUsernameProblemLanguageResultExecution timeMemory
959438NemanjaSo2005Arranging Shoes (IOI19_shoes)C++17
Compilation error
0 ms0 KiB
#include "shoes.h" #include<bits/stdc++.h> #define ll long long using namespace std; const int maxn=2e5+5; int 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(); return (N/2-1)*(N/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; } #include <cstdio> #include <cassert> using namespace std; int main() { int n; assert(1 == scanf("%d", &n)); vector<int> S(2 * n); for (int i = 0; i < 2 * n; i++) assert(1 == scanf("%d", &S[i])); fclose(stdin); long long result = count_swaps(S); printf("%lld\n", result); fclose(stdout); return 0; }

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 | }
      | ^
/usr/bin/ld: /tmp/cc1Da9DX.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccp6ZzQU.o:shoes.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status