Submission #412188

# Submission time Handle Problem Language Result Execution time Memory
412188 2021-05-26T15:24:08 Z nichke Xylophone (JOI18_xylophone) C++14
0 / 100
1 ms 200 KB
#include <bits/stdc++.h>
using namespace std;

void answer(int a, int b);
int query(int a, int b);

void solve(int n) {
	vector<int> ans(n + 1);
	vector<int> d1(n + 1);
	vector<int> d2(n + 1);
	for (int i = 1; i < n; i++) {
		d1[i - 1] = query(i, i + 1);
		if (i + 1 < n) {
			d2[i - 1] = query(i, i + 2); 
		}
	}
	ans[0] = 0;
	ans[1] = d1[1];
	int tm = 1;
	for (int i = 2; i < n; i++) {
		if (d2[i - 2] != d1[i - 1] + d1[i - 2]) {
			tm *= -1;
		}
		ans[i] = ans[i - 1] + d1[i - 1] * tm;
	}
	int mn = 1, mx = 1;
	int mnv = 0, mxv = 0;
	for (int i = 2; i <= n; i++) {
		if (ans[i] < ans[mn]) {
			mn = i;
			mnv = ans[i];
		}
		if (ans[i] > ans[mx]) {
			mx = i;
			mxv = ans[i];
		}
	}
	if (mn < mx) {
		for (int i = 0; i < n; i++) {
			answer(i + 1, ans[i] - mnv + 1);
		}
	} else {
		for (int i = 0; i < n; i++) {
			answer(i + 1, mxv - ans[i] + 1);
		}
	}
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 200 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 200 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 200 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -