This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef int64_t llo;
#define mp make_pair
#define pb push_back
#define a first
#define b second
#include "xylophone.h"
/*void answer(int x,int y){
cout<<x<<","<<y<<endl;
}
int query(int x,int y){
cout<<x<<" "<<y<<endl;
int yy;
cin>>yy;
return yy;
}*/
void solve(int n){
if(n==2){
answer(1,1);
answer(2,2);
return ;
}
int aa[n];
for(int i=0;i<n-1;i++){
aa[i]=query(i+1,i+2);
}
int bb[n];
for(int i=0;i<n-2;i++){
bb[i]=query(i+1,i+3);
}
int ans[n];
ans[0]=0;
int le=0;
for(int i=0;i<n-1;i++){
if(le==0){
ans[i+1]=ans[i]+aa[i];
}
else{
ans[i+1]=ans[i]-aa[i];
}
if(i<n-2){
if(bb[i]==max(aa[i],aa[i+1])){
le=1-le;
}
}
}
int mi;
/* for(int i=0;i<n;i++){
cout<<ans[i]<<" ";
}
cout<<endl;*/
for(int i=0;i<n;i++){
if(i==0){
mi=ans[i];
}
else{
mi=min(mi,ans[i]);
}
}
int ind;
int ind2;
for(int i=0;i<n;i++){
ans[i]+=(-mi+1);
if(ans[i]==1){
ind=i;
}
if(ans[i]==n){
ind2=i;
}
}
if(ind<ind2){
// cout<<11<<endl;
for(int i=0;i<n;i++){
answer(i+1,ans[i]);
}
return;
}
ans[0]=0;
le=1;
for(int i=0;i<n-1;i++){
if(le==0){
ans[i+1]=ans[i]+aa[i];
}
else{
ans[i+1]=ans[i]-aa[i];
}
if(i<n-2){
if(bb[i]==max(aa[i],aa[i+1])){
le=1-le;
}
}
}
for(int i=0;i<n;i++){
if(i==0){
mi=ans[i];
}
else{
mi=min(mi,ans[i]);
}
}
for(int i=0;i<n;i++){
ans[i]+=(-mi+1);
if(ans[i]==1){
ind=i;
}
if(ans[i]==n){
ind2=i;
}
}
for(int i=0;i<n;i++){
answer(i+1,ans[i]);
}
return;
}
/*int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
solve(5);
return 0;
}*/
Compilation message (stderr)
xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:73:2: warning: 'ind' may be used uninitialized in this function [-Wmaybe-uninitialized]
if(ind<ind2){
^~
xylophone.cpp:73:2: warning: 'ind2' may be used uninitialized in this function [-Wmaybe-uninitialized]
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |