Submission #780741

# Submission time Handle Problem Language Result Execution time Memory
780741 2023-07-12T12:32:22 Z JoenPoenMan Xylophone (JOI18_xylophone) C++17
47 / 100
87 ms 416 KB
#include "xylophone.h"
#include <bits/stdc++.h>

using namespace std;
typedef pair<int, int> ii;

vector<ii> locations;

void findNext2(int N, int top, int bot, int prevLoc, bool gr1);

void findNext1(int N, int top, int bot = 1, int prevLoc = 1, bool gr1 = false, bool exl = false) {
	if (top == bot) return;
	int mid;
	int low = bot, high = top;
	int prev = query(low, high);
	if (abs(top - bot) != 1) {
		while (low != high) {
			mid = (low+high)/2;
			int res = query(bot, mid);
			if (res == prev) high = mid;
			else low = mid+1;
		}
	} else low = top;
	locations.push_back({prevLoc+prev*(gr1?-1:1), low});
	findNext1(N, top, low, prevLoc+prev*(gr1?-1:1), !gr1, true);
	findNext2(N, low, bot + exl, prevLoc+prev*(gr1?-1:1), !gr1);
}

void findNext2(int N, int top, int bot, int prevLoc = 1, bool gr1 = false ) {
	if (top == bot) return;
	int mid;
	int low = bot, high = top;
	int prev = query(low, high);
	if (abs(top - bot) != 1) {
		while (low != high) {
			mid = (low+high+1)/2;
			int res = query(mid, top);
			if (res == prev) low = mid;
			else high = mid-1;
		}
	} else low = bot;
	locations.push_back({prevLoc+prev*(gr1?-1:1), low});
	findNext1(N, top-1, low, prevLoc+prev*(gr1?-1:1), !gr1, true);
	findNext2(N, low, bot, prevLoc+prev*(gr1?-1:1), !gr1);
}

void solve(int N) {
	findNext1(N, N);
	for (int i = 0; i < N; i++) {
		answer(locations[i].second, locations[i].first);
	}
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 2 ms 208 KB Output is correct
5 Correct 5 ms 296 KB Output is correct
6 Correct 4 ms 208 KB Output is correct
7 Correct 2 ms 208 KB Output is correct
8 Correct 2 ms 208 KB Output is correct
9 Correct 5 ms 304 KB Output is correct
10 Correct 6 ms 296 KB Output is correct
11 Correct 3 ms 296 KB Output is correct
12 Correct 4 ms 208 KB Output is correct
13 Correct 3 ms 208 KB Output is correct
14 Correct 3 ms 208 KB Output is correct
15 Correct 3 ms 296 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 2 ms 208 KB Output is correct
5 Correct 5 ms 296 KB Output is correct
6 Correct 4 ms 208 KB Output is correct
7 Correct 2 ms 208 KB Output is correct
8 Correct 2 ms 208 KB Output is correct
9 Correct 5 ms 304 KB Output is correct
10 Correct 6 ms 296 KB Output is correct
11 Correct 3 ms 296 KB Output is correct
12 Correct 4 ms 208 KB Output is correct
13 Correct 3 ms 208 KB Output is correct
14 Correct 3 ms 208 KB Output is correct
15 Correct 3 ms 296 KB Output is correct
16 Correct 6 ms 208 KB Output is correct
17 Correct 10 ms 208 KB Output is correct
18 Correct 16 ms 300 KB Output is correct
19 Correct 21 ms 208 KB Output is correct
20 Correct 30 ms 312 KB Output is correct
21 Correct 18 ms 208 KB Output is correct
22 Correct 25 ms 296 KB Output is correct
23 Correct 44 ms 304 KB Output is correct
24 Correct 41 ms 416 KB Output is correct
25 Correct 87 ms 376 KB Output is correct
26 Correct 29 ms 304 KB Output is correct
27 Correct 21 ms 296 KB Output is correct
28 Correct 25 ms 296 KB Output is correct
29 Correct 23 ms 300 KB Output is correct
30 Correct 26 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 2 ms 208 KB Output is correct
5 Correct 5 ms 296 KB Output is correct
6 Correct 4 ms 208 KB Output is correct
7 Correct 2 ms 208 KB Output is correct
8 Correct 2 ms 208 KB Output is correct
9 Correct 5 ms 304 KB Output is correct
10 Correct 6 ms 296 KB Output is correct
11 Correct 3 ms 296 KB Output is correct
12 Correct 4 ms 208 KB Output is correct
13 Correct 3 ms 208 KB Output is correct
14 Correct 3 ms 208 KB Output is correct
15 Correct 3 ms 296 KB Output is correct
16 Correct 6 ms 208 KB Output is correct
17 Correct 10 ms 208 KB Output is correct
18 Correct 16 ms 300 KB Output is correct
19 Correct 21 ms 208 KB Output is correct
20 Correct 30 ms 312 KB Output is correct
21 Correct 18 ms 208 KB Output is correct
22 Correct 25 ms 296 KB Output is correct
23 Correct 44 ms 304 KB Output is correct
24 Correct 41 ms 416 KB Output is correct
25 Correct 87 ms 376 KB Output is correct
26 Correct 29 ms 304 KB Output is correct
27 Correct 21 ms 296 KB Output is correct
28 Correct 25 ms 296 KB Output is correct
29 Correct 23 ms 300 KB Output is correct
30 Correct 26 ms 208 KB Output is correct
31 Correct 51 ms 328 KB Output is correct
32 Correct 78 ms 304 KB Output is correct
33 Incorrect 81 ms 316 KB Wrong Answer [2]
34 Halted 0 ms 0 KB -