제출 #565700

#제출 시각아이디문제언어결과실행 시간메모리
565700haxormanXylophone (JOI18_xylophone)C++14
0 / 100
1 ms208 KiB
#include "xylophone.h" #include <bits/stdc++.h> using namespace std; int arr[5001]; void solve(int n) { map<int,int> pos; for (int i = 2; i <= n; ++i) { int dif = query(i, n); if (dif < n - 1) { arr[i - 1] = 1; pos[1] = i - 1; break; } } for (int i = pos[1]; i < n; ++i) { int dif = query(i, i + 1); int big = arr[i] + dif; int small = arr[i] - dif; if (pos.count(small) || small < 1) { arr[i + 1] = big; pos[big] = i + 1; } else if (pos.count(big) || big > n) { arr[i + 1] = small; pos[small] = i + 1; } else { int new_dif = query(i - 1, i + 1); if (arr[i - 1] > arr[i]) { if (dif < new_dif) { arr[i + 1] = big; pos[big] = i + 1; } else { arr[i + 1] = small; pos[small] = i + 1; } } else { if (dif < new_dif) { arr[i + 1] = small; pos[small] = i + 1; } else { arr[i + 1] = big; pos[big] = i + 1; } } } } for (int i = pos[1]; i > 1; --i) { int dif = query(i - 1, i); int big = arr[i] + dif; int small = arr[i] - dif; if (pos.count(small) || small < 1) { arr[i - 1] = big; pos[big] = i + 1; } else if (pos.count(big) || big > n) { arr[i - 1] = small; pos[small] = i + 1; } else { int new_dif = query(i - 1, i + 1); if (arr[i + 1] > arr[i]) { if (dif < new_dif) { arr[i - 1] = big; pos[big] = i + 1; } else { arr[i - 1] = small; pos[small] = i + 1; } } else { if (dif < new_dif) { arr[i - 1] = small; pos[small] = i + 1; } else { arr[i - 1] = big; pos[big] = i + 1; } } } } for (int i = 1; i <= n; ++i) { //cout << arr[i] << ' '; answer(i, arr[i]); } //cout << "\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...