This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#include "xylophone.h"
#define ll long long
#define ld long double
#define pb push_back
#define fi first
#define se second
#define en '\n'
#define sp ' '
#define tb '\t'
#define ri(n) int n; cin >> n
#define rl(n) ll n; cin >> n
#define rs(s) string s; cin >> s
#define rc(c) char c; cin >> c
#define rv(v) for (auto &x : v) cin >> x
#define pven(v) for (auto x : v) cout << x << en
#define pv(v) for (auto x : v) cout << x << sp; cout << en
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define yes cout << "YES" << en
#define no cout << "NO" << en
#define smin(a, b) a = min(a, b)
#define smax(a, b) a = max(a, b)
#define ssort(a, b) if (a < b) swap(a, b)
#define bitcnt(a) (__builtin_popcountll(a))
#define bithigh(a) (63-__builtin_clzll(a))
#define lg bithigh
#define highpow(a) (1LL << (ll)lg(a))
using namespace std;
const ll LINF = 4e18;
const int mxN = 1e6+10, INF = 2e9;
ll n, m, a[mxN], b[2][mxN];
void solve(int N){
for (int i = 2; i <= N; i++) b[0][i] = query(i-1, i);
for (int i = 3; i <= N; i++) b[1][i] = query(i-2, i);
a[1] = 0; a[2] = b[0][2];
for (int i = 3; i <= N; i++){
int t1 = (b[0][i-1] + b[0][i] == b[1][i] ? 1 : -1);
int t2 = (a[i-1] > a[i-2] ? 1 : -1);
a[i] = a[i-1] + t1*t2*b[0][i];
}
array<int, 2> idx = {1, 1};
for (int i = 2; i <= N; i++){
if (a[i] < a[idx[0]]) idx[0] = i;
if (a[i] > a[idx[1]]) idx[1] = i;
}
if (idx[0] > idx[1]){
for (int i = 1; i <= N; i++)
a[i] *= -1;
swap(idx[0], idx[1]);
}
int d = 1-a[idx[0]];
for (int i = 1; i <= N; i++)
answer(i, a[i]+d);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |