제출 #1154697

#제출 시각아이디문제언어결과실행 시간메모리
1154697nguynXylophone (JOI18_xylophone)C++20
0 / 100
0 ms428 KiB
#include <bits/stdc++.h> #include "xylophone.h" using namespace std; #define ll long long #define F first #define S second #define pb push_back #define pii pair<int, int> int d[5005]; int a[5005]; void solve(int n) { int id = 1; int mx = 0; for (int i = 2; i <= n; i++) { int t = query(1, i); if (t > mx) { mx = t; id = i; } } int id2 = 0; for (int i = id + 1; i <= n; i++) { if (!id2) { int t = query(id, i); d[i] = t; if (t == n - 1) { id2 = i; } } else { int t = query(id2, i); d[i] = t; } } if (id < id2) { a[id] = 1; a[id2] = n; for (int i = id + 1; i < id2; i++) { a[i] = 1 + d[i]; } for (int i = id2 + 1; i <= n; i++) { a[i] = n - d[i]; } for (int i = 1; i < id; i++) { int t = query(1, id); a[i] = 1 + a[i]; } } else { a[id] = n; for (int i = id + 1; i <= n; i++) { a[i] = n - d[i]; } for (int i = id - 1; i >= 1; i--) { if (!id2) { int t = query(i, id); a[i] = n - t; if (t == n - 1) { id2 = i; } } else { int t = query(i, id2); a[i] = 1 + t; } } } 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...