Submission #1118914

#TimeUsernameProblemLanguageResultExecution timeMemory
1118914SofiatpcXylophone (JOI18_xylophone)C++17
100 / 100
183 ms988 KiB
#include <bits/stdc++.h> #include "xylophone.h" using namespace std; int x[5005], y[5005], v[5005]; int calc(int a, int b, int x, int y){ if(abs(a-b) != y && x != y){ if(a > b)return b-x; return b+x; }else{ if(a > b)return b+x; return b-x; } } void solve(int n) { v[1] = 1; x[2] = query(1,2); v[2] = 1+x[2]; for(int i = 3; i <= n; i++){ x[i] = query(i-1,i), y[i] = query(i-2,i); v[i] = calc(v[i-2],v[i-1], x[i], y[i]); } int idmn = 1, idmx = 2; for(int i = 2; i <= n; i++){ if(v[idmn] > v[i])idmn = i; if(v[idmx] < v[i])idmx = i; } if(idmn > idmx){ v[2] = v[1] - x[2]; for(int i = 3; i <= n; i++) v[i] = calc(v[i-2],v[i-1], x[i], y[i]); idmn = 2, idmn = 1; for(int i = 2; i <= n; i++){ if(v[idmn] > v[i])idmn = i; if(v[idmx] < v[i])idmx = i; } } for(int i = 1; i <= n; i++) answer(i,v[i]-v[idmn]+1); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...