Submission #581823

#TimeUsernameProblemLanguageResultExecution timeMemory
581823YaserFaisalXylophone (JOI18_xylophone)C++14
0 / 100
43 ms98172 KiB
#include "xylophone.h" #include <bits/stdc++.h> using namespace std; static int A[5000]; void solve(int n) { int l = 2 ; int a[5001] ; int q[5001][5001] ; int one = 1 ; while ( true ) { q[l][n] = query(l,n) ; if ( q[l][n] != n-1 ) break ; l++ ; one++ ; } a[one] = 1 ; for ( int i = one-1 ; i >= 1 ; i-- ) { int x = query(i,i+1) ; q[i][i+1] = x ; if ( a[i+1]-x <= 1 ) a[i] = a[i+1]+x ; else if ( a[i+1]+x >= n ) a[i] = a[i+1]-x ; else { int y = query(i,i+2) ; q[i][i+2] = y ; if ( a[i+1] > a[i+2] ) { if ( y == q[i+1][i+2] || y == x ) a[i] = a[i+1]-x ; else a[i] = a[i+1]+x ; } else { if ( y == q[i+1][i+2] || y == x ) a[i] = a[i+1]+x ; else a[i] = a[i+1]-x ; } } } for ( int i = one+1 ; i <= n ; i++ ) { int x = query(i-1,i) ; q[i-1][i] = x ; if ( a[i-1]-x <= 1 ) a[i] = a[i-1]+x ; else if ( a[i-1]+x >= n ) a[i] = a[i-1]-x ; else { int y = query(i-2,i) ; q[i-2][i] = y ; if ( a[i-1] > a[i-2] ) { if ( y == q[i-2][i-1] || y == x ) a[i] = a[i-1]-x ; else a[i] = a[i-1]+x ; } else { if ( y == q[i-2][i-1] || y == x ) a[i] = a[i-1]+x ; else a[i] = a[i-1]-x ; } } } for ( int i = 1 ; i <= n ; i++ ) answer(i,a[i]) ; } //query(s,t) , return abs(A[s]-A[t]) // answer(i,a) , A[i] = a

Compilation message (stderr)

xylophone.cpp:5:12: warning: 'A' defined but not used [-Wunused-variable]
    5 | static int A[5000];
      |            ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...