Submission #307810

#TimeUsernameProblemLanguageResultExecution timeMemory
307810juggernautGondola (IOI14_gondola)C++14
Compilation error
0 ms0 KiB
#include"gondola.h" #include<bits/stdc++.h> #include"grader.cpp" using namespace std; int valid(int n,int a[]){ int i=0,need; while(i<n&&a[i]>n)i++; need=a[i]; while(i<n){ if(a[i]<=n&&a[i]!=need)return 0; if(need==n)need=1; else need++; i++; } sort(a,a+n); for(i=1;i<n;i++)if(a[i]==a[i-1])return 0; return 1; } int replacement(int n,int a[],int res[]){ vector<pair<int,int>>b; int i=0,ind=n,need=1,len=0,x; while(i<n&&a[i]>n)i++; if(i!=n)need=a[i]-i; if(need<1)need+=n; for(i=0;i<n;i++,need=need%n+1)b.push_back({a[i],need}); sort(b.begin(),b.end()); i=0; while(i<n){ if(b[i].first<=n){ i++; continue; } res[len++]=b[i].second; x=++ind; while(x!=b[i].first){ res[len++]=x; x=++ind; } i++; } return len; } int countReplacement(int n,int a[]){ if(!valid(n,a))return 0; vector<pair<int,int>>b; int i=0,ind=n,need=1,len=0,x; long long cnt=1,mod=1e9+7,y; while(i<n&&a[i]>n)i++; if(i!=n)need=a[i]-i; if(need<1)need+=n; for(i=0;i<n;i++,need=need%n+1)b.push_back({a[i],need}); sort(b.begin(),b.end()); i=0; while(i<n){ if(b[i].first<=n){ i++; continue; } y=b[i].first-ind; ind=b[i].first; cnt=(cnt*y)%mod; i++; } return cnt; }

Compilation message (stderr)

gondola.cpp: In function 'int countReplacement(int, int*)':
gondola.cpp:46:26: warning: unused variable 'len' [-Wunused-variable]
   46 |     int i=0,ind=n,need=1,len=0,x;
      |                          ^~~
gondola.cpp:46:32: warning: unused variable 'x' [-Wunused-variable]
   46 |     int i=0,ind=n,need=1,len=0,x;
      |                                ^
/tmp/ccw1bv0O.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/cc2LzfWy.o:gondola.cpp:(.text.startup+0x0): first defined here
/tmp/ccw1bv0O.o:(.bss+0xf4260): multiple definition of `gondolaSequence'
/tmp/cc2LzfWy.o:(.bss+0xf4260): first defined here
/tmp/ccw1bv0O.o:(.bss+0x0): multiple definition of `replacementSequence'
/tmp/cc2LzfWy.o:(.bss+0x0): first defined here
collect2: error: ld returned 1 exit status