제출 #776712

#제출 시각아이디문제언어결과실행 시간메모리
776712NothingXDXylophone (JOI18_xylophone)C++17
100 / 100
88 ms424 KiB
#include "xylophone.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef double ld; typedef pair<int,int> pii; typedef pair<ll,ll> pll; typedef complex<ld> point; void debug_out(){cerr << endl;} template<typename Head, typename... Tail> void debug_out(Head H, Tail... T){ cout << H << ' '; debug_out(T...); } #define debug(...) cerr << "(" << #__VA_ARGS__ << "): ", debug_out(__VA_ARGS__); #define F first #define S second #define all(x) x.begin(), x.end() #define MP(x, y) make_pair(x, y) const int maxn = 5e3 + 10; static int n, a[maxn], b[maxn]; void build(){ int mn = 0; a[0] = 0; for (int i = 1; i < n; i++){ a[i] = a[i-1] + b[i]; mn = min(mn, a[i]); } for (int i = 0; i < n; i++){ a[i] += 1 - mn; } } void solve(int N) { n = N; b[1] = query(1, 2); for (int i = 2; i < n; i++){ b[i] = query(i, i+1); if (b[i-1] < 0) b[i] *= -1; if (abs(b[i-1]) + abs(b[i]) != query(i-1, i+1)) b[i] *= -1; } build(); int tmp = 0; for (int i = 0; i < n; i++){ if (a[i] == 1) tmp += i; if (a[i] == n) tmp -= i; } if (tmp > 0){ for (int i = 1; i < n; i++) b[i] *= -1; build(); } for (int i = 0; i < n; i++){ answer(i+1, a[i]); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...