Submission #209541

#TimeUsernameProblemLanguageResultExecution timeMemory
209541DodgeBallManXylophone (JOI18_xylophone)C++14
100 / 100
99 ms380 KiB
#include <bits/stdc++.h> #include "xylophone.h" using namespace std; const int N = 5e3 + 10; int a[N], df[N], st[N], mul = 1, mn, mx, pmn, pmx; //void answer( int pos, int va ) { printf("pos : %d va : %d\n",pos,va); } /*int query( int i, int j ) { int c; printf("%d %d\n",i,j); scanf("%d",&c); return c; }*/ void solve( int n ) { for( int i = 1 ; i < n ; i++ ) df[i+1] = query( i, i + 1 ); for( int i = 2 ; i < n ; i++ ) { int dif = query( i-1, i+1 ); if( dif == df[i] + df[i+1] ) st[i] = 1; else st[i] = -1; } pmx = 1, pmn = 1; for( int i = 2 ; i <= n ; i++ ) { a[i] = a[i-1] + ( mul * df[i] ); mul *= st[i]; if( a[i] > mx ) mx = a[i], pmx = i; if( a[i] < mn ) mn = a[i], pmn = i; } /*for( int i = 2 ; i <= n ; i++ ) printf("%d ",df[i]); printf("\n"); for( int i = 2 ; i < n ; i++ ) printf("%d ",st[i]); printf("\n"); printf("%d %d pos : %d %d\n",mn,mx,pmn,pmx);*/ if( pmn > pmx ) { for( int i = 1 ; i <= n ; i++) a[i] *= -1; swap( mn, mx ); mn *= -1, mx *= -1; } //printf("%d %d pos : %d %d\n",mn,mx,pmn,pmx); for( int i = 1 ; i <= n ; i++ ) answer( i, a[i] + -1*mn + 1 ); } /*int main() { int n; scanf("%d",&n); solve( n ); }*/
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...