제출 #679579

#제출 시각아이디문제언어결과실행 시간메모리
679579Doncho_BonbonchoXylophone (JOI18_xylophone)C++14
0 / 100
2 ms308 KiB
#include <bits/stdc++.h> #include "xylophone.h" const int MAX_N = 8192; static int a[MAX_N]; int two[MAX_N]; int tri[MAX_N]; bool otn[MAX_N]; // i and i+1 void solve(int n) { for( int i=1 ; i<n ; i++ ){ two[i] = query( i, i+1 );; } for( int i=1 ; i<n-1 ; i++ ){ tri[i] = query( i, i+2 );; } otn[1] = 1; for( int i=1 ; i<n-1; i++ ){ if( tri[i] == two[i] + two[i+1] ) otn[i+1] = otn[i]; else otn[i+1] = !otn[i]; } int min = 1, max = 1; a[1] = 0; for( int i=1 ; i<n ; i++ ){ if( otn[i] ) a[i+1] = a[i] - two[i]; else a[i+1] = a[i] + two[i]; if( a[min] > a[i] ) min = i; if( a[max] < a[i] ) max = i; } /* std::cerr<<" ! "<<min<<" "<<max<<" -> "<<a[min]<<" "<<a[max]<<"\n"; for( int i=1 ; i<=n ; i++ ) std::cerr<<a[i]<<" "; std::cerr<<"\n"; */ if( min < max ){ for( int i=1; i<=n ; i++ ){ answer( i, a[i] + 1 - a[min] ); } return ; }//else std::cerr<<" ne stava \n\n\n\n "; min = 1, max = 1; a[1] = 0; for( int i=1 ; i<n ; i++ ){ if( otn[i] ) a[i+1] = a[i] + two[i]; else a[i+1] = a[i] - two[i]; if( a[min] > a[i] ) min = i; if( a[max] < a[i] ) max = i; } /* for( int i=1 ; i<=n ; i++ ) std::cerr<<a[i]<<" "; std::cerr<<"\n"; */ for( int i=1; i<=n ; i++ ){ answer( i, a[i] + 1 - a[min] ); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...