Submission #895857

# Submission time Handle Problem Language Result Execution time Memory
895857 2023-12-31T00:13:02 Z starchan Xylophone (JOI18_xylophone) C++17
47 / 100
46 ms 692 KB
#include "xylophone.h"
#include<bits/stdc++.h>
using namespace std;
#define in pair<int, int>
#define f first
#define s second
#define pb push_back
#define pob pop_back
#define INF (int)1e17
#define MX (int)3e5+5
#define fast() ios_base::sync_with_stdio(false); cin.tie(NULL)
void solve(int n)
{
	if(n == 2)
	{
		answer(1, 1);
		answer(2, 2);
		return;
	}
	int l = 1;
	int r = n;
	while(l < r)
	{
		int m = (l+r)/2;
		int t = query(m, n);
		if(t != (n-1))
			r = m;
		else
			l = m+1;
	}
	l--;
	vector<int> d(n+1);
	vector<int> d2(n+1);
	vector<int> a(n+1);
	for(int i = 2; i <= n; i++)
		d[i] = query(i-1, i);
	a[l] = 1;
	if(l >= 2)
		a[l-1] = 1+d[l];
	a[l+1] = 1+d[l+1];
	for(int i = 3; i <= n; i++)
		d2[i] = query(i-2, i);
	for(int i = l+2; i <= n; i++)
	{
		if(d2[i] == (d[i]+d[i-1]))
		{
			if(a[i-2] > a[i-1])
				a[i] = a[i-1]-d[i];
			else
				a[i] = a[i-1]+d[i];
		}
		else
		{
			if(a[i-2] > a[i-1])
				a[i] = a[i-1]+d[i];
			else
				a[i] = a[i-1]-d[i];
		}
	}
	for(int i = l-2; i >= 1; i--)
	{
		//a[i] a[i+1] a[i+2]
		if(d2[i+2] == (d[i+2]+d[i+1]))
		{
			if(a[i+1] < a[i+2])
				a[i] = a[i+1]-d[i+1];
			else
				a[i] = a[i+1]+d[i+1];
		}
		else
		{
			if(a[i+1] < a[i+2])
				a[i] = a[i+1]+d[i+1];
			else
				a[i] = a[i+1]-d[i+1];
		}
	}
	for(int i = 1; i <= n; i++)
		answer(i, a[i]);
	return;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 596 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 596 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 3 ms 432 KB Output is correct
17 Correct 5 ms 432 KB Output is correct
18 Correct 7 ms 436 KB Output is correct
19 Correct 7 ms 608 KB Output is correct
20 Correct 7 ms 436 KB Output is correct
21 Correct 9 ms 448 KB Output is correct
22 Correct 7 ms 432 KB Output is correct
23 Correct 7 ms 692 KB Output is correct
24 Correct 8 ms 688 KB Output is correct
25 Correct 7 ms 688 KB Output is correct
26 Correct 8 ms 436 KB Output is correct
27 Correct 8 ms 688 KB Output is correct
28 Correct 9 ms 588 KB Output is correct
29 Correct 10 ms 448 KB Output is correct
30 Correct 7 ms 448 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 596 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 3 ms 432 KB Output is correct
17 Correct 5 ms 432 KB Output is correct
18 Correct 7 ms 436 KB Output is correct
19 Correct 7 ms 608 KB Output is correct
20 Correct 7 ms 436 KB Output is correct
21 Correct 9 ms 448 KB Output is correct
22 Correct 7 ms 432 KB Output is correct
23 Correct 7 ms 692 KB Output is correct
24 Correct 8 ms 688 KB Output is correct
25 Correct 7 ms 688 KB Output is correct
26 Correct 8 ms 436 KB Output is correct
27 Correct 8 ms 688 KB Output is correct
28 Correct 9 ms 588 KB Output is correct
29 Correct 10 ms 448 KB Output is correct
30 Correct 7 ms 448 KB Output is correct
31 Correct 24 ms 680 KB Output is correct
32 Correct 23 ms 452 KB Output is correct
33 Correct 34 ms 680 KB Output is correct
34 Incorrect 46 ms 432 KB Wrong Answer [2]
35 Halted 0 ms 0 KB -