Submission #428558

# Submission time Handle Problem Language Result Execution time Memory
428558 2021-06-15T12:52:12 Z pavement Park (JOI17_park) C++17
37 / 100
270 ms 460 KB
#include "park.h"
#include <bits/stdc++.h>
using namespace std;

#define mp make_pair
#define pb push_back

static int N, Place[1405], link[1405], sz[1405];

int find(int x) {
	if (x == link[x]) return x;
	return link[x] = find(link[x]);
}

void unite(int a, int b) {
	a = find(a);
	b = find(b);
	if (a == b) return;
	if (sz[b] > sz[a]) swap(a, b);
	sz[a] += sz[b];
	link[b] = a;
}

void solve(int l, int r) {
	if (find(l) == find(r)) return;
	int lo = 0, hi = N - 1, ans = -1;
	while (lo <= hi) {
		int mid = (lo + hi) / 2;
		memset(Place, 0, sizeof Place);
		for (int i = 0; i <= mid; i++)
			Place[i] = 1;
		Place[l] = Place[r] = 1;
		if (l >= r ? Ask(r, l, Place) : Ask(l, r, Place)) ans = mid, hi = mid - 1;
		else lo = mid + 1;
	}
	if (ans == 0) {
		l >= r ? Answer(r, l) : Answer(l, r);
		unite(l, r);
	} else {
		solve(l, ans);
		solve(ans, r);
	}
}

void Detect(int T, int N) {
	::N = N;
	for (int i = 0; i < N; i++) {
		link[i] = i;
		sz[i] = 1;
	}
	for (int i = 1; i < N; i++)
		solve(0, i);
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Wrong Answer[6]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 40 ms 436 KB Output is correct
2 Correct 114 ms 448 KB Output is correct
3 Correct 113 ms 440 KB Output is correct
4 Correct 38 ms 456 KB Output is correct
5 Correct 66 ms 460 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 166 ms 400 KB Output is correct
2 Correct 220 ms 388 KB Output is correct
3 Correct 172 ms 392 KB Output is correct
4 Correct 162 ms 392 KB Output is correct
5 Correct 166 ms 396 KB Output is correct
6 Correct 156 ms 388 KB Output is correct
7 Correct 198 ms 388 KB Output is correct
8 Correct 218 ms 396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 117 ms 368 KB Output is correct
2 Incorrect 159 ms 392 KB Wrong Answer[5]
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 270 ms 408 KB Wrong Answer[6]
2 Halted 0 ms 0 KB -