Submission #501784

#TimeUsernameProblemLanguageResultExecution timeMemory
501784lovrotXylophone (JOI18_xylophone)C++11
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; int rj[10000]; int main (){ int n; cin >> n; int p; for (int i=n;i>0;i--){ cout<<"query("<<1<<", "<<i<<")"<<endl; int odg; cin>>odg; if (odg<n-1){ rj[i+1]=n; p=i+1; break; } } if (n!=p){ cout<<"query("<<p<<", "<<p+1<<")"<<endl; int odg; cin>>odg; rj[p+1]=n-odg; } if (1!=p){ cout<<"query("<<p<<", "<<p-1<<")"<<endl; int odg; cin>>odg; rj[p-1]=n-odg; } for (int i=p+2;i<n+1;i++){ cout<<"query("<<i-1<<", "<<i<<")"<<endl; int odg1; cin>>odg1; cout<<"query("<<i-2<<", "<<i<<")"<<endl; int odg2; cin>>odg2; if (rj[i-1]>rj[i-2]){ if (odg2==rj[i-1]-rj[i-2]+odg1){ rj[i]=rj[i-1]+odg1; } else { rj[i]=rj[i-1]-odg1; } } else { if (odg2==rj[i-2]-rj[i-1]+odg1){ rj[i]=rj[i-1]-odg1; } else { rj[i]=rj[i-1]+odg1; } } } for (int i=p-2;i>0;i--){ cout<<"query("<<i+1<<", "<<i<<")"<<endl; int odg1; cin>>odg1; cout<<"query("<<i+2<<", "<<i<<")"<<endl; int odg2; cin>>odg2; if (rj[i+1]>rj[i+2]){ if (odg2==rj[i+1]-rj[i+2]+odg1){ rj[i]=rj[i+1]+odg1; } else { rj[i]=rj[i+1]-odg1; } } else { if (odg2==rj[i+2]-rj[i+1]+odg1){ rj[i]=rj[i+1]-odg1; } else { rj[i]=rj[i+1]+odg1; } } } for (int i=1;i<n+1;i++){ cout<<rj[i]<<" "; } return 0; }

Compilation message (stderr)

xylophone.cpp: In function 'int main()':
xylophone.cpp:11:6: warning: 'p' may be used uninitialized in this function [-Wmaybe-uninitialized]
   11 |  int p;
      |      ^
/usr/bin/ld: /tmp/ccFpdT29.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccUmB6Ca.o:xylophone.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccFpdT29.o: in function `main':
grader.cpp:(.text.startup+0x30): undefined reference to `solve(int)'
collect2: error: ld returned 1 exit status