Submission #777154

# Submission time Handle Problem Language Result Execution time Memory
777154 2023-07-08T18:05:06 Z JoenPoenMan Xylophone (JOI18_xylophone) C++17
47 / 100
90 ms 440 KB
#include "xylophone.h"
#include <bits/stdc++.h>

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

static int A[5000];

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);
	while (low != high) {
		mid = (low+high)/2;
		int res = query(bot, mid);
		if (res == prev) high = mid;
		else low = mid+1;
	}
	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);
	while (low != high) {
		mid = (low+high+1)/2;
		int res = query(mid, top);
		if (res == prev) low = mid;
		else high = mid-1;
	}
	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);
	sort(locations.begin(), locations.end());
	bool oppdir = (locations[0].second > locations.back().second);
	for (int i = 0; i < N; i++) {
		answer(locations[i].second, (oppdir ? N-i : i + 1));
	}
	
	
}

Compilation message

xylophone.cpp:7:12: warning: 'A' defined but not used [-Wunused-variable]
    7 | static int A[5000];
      |            ^
# 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 3 ms 208 KB Output is correct
5 Correct 6 ms 304 KB Output is correct
6 Correct 3 ms 304 KB Output is correct
7 Correct 3 ms 208 KB Output is correct
8 Correct 3 ms 304 KB Output is correct
9 Correct 7 ms 296 KB Output is correct
10 Correct 8 ms 208 KB Output is correct
11 Correct 2 ms 300 KB Output is correct
12 Correct 2 ms 300 KB Output is correct
13 Correct 3 ms 208 KB Output is correct
14 Correct 2 ms 300 KB Output is correct
15 Correct 3 ms 336 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 3 ms 208 KB Output is correct
5 Correct 6 ms 304 KB Output is correct
6 Correct 3 ms 304 KB Output is correct
7 Correct 3 ms 208 KB Output is correct
8 Correct 3 ms 304 KB Output is correct
9 Correct 7 ms 296 KB Output is correct
10 Correct 8 ms 208 KB Output is correct
11 Correct 2 ms 300 KB Output is correct
12 Correct 2 ms 300 KB Output is correct
13 Correct 3 ms 208 KB Output is correct
14 Correct 2 ms 300 KB Output is correct
15 Correct 3 ms 336 KB Output is correct
16 Correct 6 ms 296 KB Output is correct
17 Correct 13 ms 296 KB Output is correct
18 Correct 22 ms 208 KB Output is correct
19 Correct 29 ms 284 KB Output is correct
20 Correct 18 ms 208 KB Output is correct
21 Correct 33 ms 336 KB Output is correct
22 Correct 29 ms 296 KB Output is correct
23 Correct 39 ms 328 KB Output is correct
24 Correct 90 ms 300 KB Output is correct
25 Correct 82 ms 440 KB Output is correct
26 Correct 24 ms 304 KB Output is correct
27 Correct 30 ms 208 KB Output is correct
28 Correct 22 ms 296 KB Output is correct
29 Correct 24 ms 304 KB Output is correct
30 Correct 18 ms 288 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 3 ms 208 KB Output is correct
5 Correct 6 ms 304 KB Output is correct
6 Correct 3 ms 304 KB Output is correct
7 Correct 3 ms 208 KB Output is correct
8 Correct 3 ms 304 KB Output is correct
9 Correct 7 ms 296 KB Output is correct
10 Correct 8 ms 208 KB Output is correct
11 Correct 2 ms 300 KB Output is correct
12 Correct 2 ms 300 KB Output is correct
13 Correct 3 ms 208 KB Output is correct
14 Correct 2 ms 300 KB Output is correct
15 Correct 3 ms 336 KB Output is correct
16 Correct 6 ms 296 KB Output is correct
17 Correct 13 ms 296 KB Output is correct
18 Correct 22 ms 208 KB Output is correct
19 Correct 29 ms 284 KB Output is correct
20 Correct 18 ms 208 KB Output is correct
21 Correct 33 ms 336 KB Output is correct
22 Correct 29 ms 296 KB Output is correct
23 Correct 39 ms 328 KB Output is correct
24 Correct 90 ms 300 KB Output is correct
25 Correct 82 ms 440 KB Output is correct
26 Correct 24 ms 304 KB Output is correct
27 Correct 30 ms 208 KB Output is correct
28 Correct 22 ms 296 KB Output is correct
29 Correct 24 ms 304 KB Output is correct
30 Correct 18 ms 288 KB Output is correct
31 Correct 58 ms 304 KB Output is correct
32 Incorrect 62 ms 304 KB Wrong Answer [2]
33 Halted 0 ms 0 KB -