Submission #478985

#TimeUsernameProblemLanguageResultExecution timeMemory
478985ponytailXylophone (JOI18_xylophone)C++17
0 / 100
1 ms200 KiB
//SUBMIT #include <bits/stdc++.h> #include "xylophone.h" using namespace std; static int A[16384]; void solve(int N) { if(N == 2) { answer(1, 1); answer(2, 2); return; } int value = query(1, N); int P[N+1]; int delta[N+1]; int one[N+1], two[N+1]; for(int i = 1; i < N; i++) { one[i] = query(i, i+1); } for(int i=1; i<N-1; i++) { two[i] = query(i, i+2); } if(one[1] + one[2] == two[1]) delta[1] = one[1], delta[2] = one[2]; else delta[1] = one[1], delta[2] = -one[2]; for(int i=3; i<N; i++) { if(one[i-1] + one[i] == two[i-1]) delta[i] = (delta[i-1] > 0 ? 1 : -1) * one[i]; else delta[i] = (delta[i-1] > 0 ? -1 : 1) * one[i]; } int mini, maxi, cur; mini = 1e9, maxi = -1e9, cur = 0; for(int i=1; i<N; i++) { cur += delta[i]; mini = min(mini, cur); maxi = max(maxi, cur); } cur = 0; int pos[N+1]; for(int i=2; i<=N; i++) { cur += delta[i-1]; P[i] = cur - mini + 1; pos[P[i]] = i; } P[1] = -mini + 1; if(pos[1] > pos[N]) { for(int i=1; i<N; i++) delta[i] *= -1; mini = 1e9, maxi = -1e9, cur = 0; for(int i=1; i<N; i++) { cur += delta[i]; mini = min(mini, cur); maxi = max(maxi, cur); } cur = 0; for(int i=2; i<=N; i++) { cur += delta[i-1]; P[i] = cur - mini + 1; } P[1] = -mini + 1; } for(int i=1; i<=N; i++) { answer(i, P[i]); } } //END SUBMIT

Compilation message (stderr)

xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:17:6: warning: unused variable 'value' [-Wunused-variable]
   17 |  int value = query(1, N);
      |      ^~~~~
xylophone.cpp: At global scope:
xylophone.cpp:9:12: warning: 'A' defined but not used [-Wunused-variable]
    9 | static int A[16384];
      |            ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...