Submission #903806

#TimeUsernameProblemLanguageResultExecution timeMemory
903806vjudge1Xylophone (JOI18_xylophone)C++17
100 / 100
54 ms1636 KiB
#include "xylophone.h" #include <iostream> #include <vector> using namespace std; int a[5005], b[5005], c[5005], dd[5005]; void solve(int n) { if (n == 2) { answer(1, 1); answer(2, 2); return; } for (int i = 1; i <= n - 1; i++) { b[i] = query(i, i + 1); } for (int i = 1; i <= n - 2; i++) { c[i] = query(i, i + 2); if (c[i] == b[i] + b[i + 1]) dd[i] = 0; else dd[i] = 1; } int d = 0, mi = 0, ma = 0, g = 0, h = 0, flag = 0, f = 0; for (int i = 1; i < n; i++) { if (flag == 1) d += b[i]; else d -= b[i]; if (ma < d) { ma = d; g = i; } if (mi > d) { mi = d; h = i; } if (flag != dd[i]) flag = 1; else flag = 0; } if (g <= h) f = 1; mi = d = 0; for (int i = 1; i < n; i++) { if (f == 1) d += b[i]; else d -= b[i]; mi = min(mi, d); if (f != dd[i]) f = 1; else f = 0; a[i + 1] = d; } for (int i = 1; i <= n; i++) { a[i] += 1 - mi; } for (int i = 1; i <= n; i++) { answer(i, a[i]); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...