답안 #1047790

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1047790 2024-08-07T16:01:12 Z vjudge1 분수 공원 (IOI21_parks) C++17
5 / 100
211 ms 49968 KB
#include "parks.h"
#include <bits/stdc++.h>
using namespace std;

#define ar array

const int dir[4][2] = {{2, 0}, {-2, 0}, {0, 2}, {0, -2}};

const int N = 3e5 + 20;

int X[N], Y[N];
map<ar<int, 2>, int > mp;

vector<int> U, V, A, B;
bool vis[N];

void dfs(int x){
	vis[x] = 1;
	for(int i = 0;i < 4;i++){
		if(mp.count(ar<int, 2>{X[x] + dir[i][0], Y[x] + dir[i][1]})){
			int u = mp[ar<int, 2>{X[x] + dir[i][0], Y[x] + dir[i][1]}];
			if(vis[u])continue;
			U.push_back(x);
			V.push_back(u);
			if(X[x] == X[u]){
				B.push_back({Y[x] + (Y[x] < Y[u] ? 1 : -1)});
				if((X[u] + Y[u]) & 2)A.push_back({X[x] + (Y[x] > Y[u] ? 1 : -1)});
				else A.push_back({X[x] + (Y[x] < Y[u] ? 1 : -1)});
			}else{
				A.push_back({X[x] + (X[x] < X[u] ? 1 : -1)});
				if((X[u] + Y[u]) & 2)B.push_back({Y[x] + (X[x] > X[u] ? 1 : -1)});
				else B.push_back({Y[x] + (X[x] < X[u] ? 1 : -1)});
			}
			dfs(u);
		}
	}
}

int construct_roads(std::vector<int> x, std::vector<int> y) {
	int n = x.size();
	for(int i = 0;i < n;i++)X[i] = x[i], Y[i] = y[i];
    for(int i = 0;i < n;i++)mp[{x[i], y[i]}] = i;
	dfs(0);
	for(int i = 0;i < n;i++){
		if(!vis[i]){
			return 0;
		}
	}
	

	build(U, V, A, B);
	return 1;
	
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 0 ms 2396 KB Output is correct
8 Correct 0 ms 2396 KB Output is correct
9 Correct 81 ms 25284 KB Output is correct
10 Correct 7 ms 4940 KB Output is correct
11 Correct 41 ms 15304 KB Output is correct
12 Correct 10 ms 6232 KB Output is correct
13 Correct 22 ms 9820 KB Output is correct
14 Correct 1 ms 2392 KB Output is correct
15 Correct 1 ms 2652 KB Output is correct
16 Correct 75 ms 20804 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 0 ms 2396 KB Output is correct
8 Correct 0 ms 2396 KB Output is correct
9 Correct 81 ms 25284 KB Output is correct
10 Correct 7 ms 4940 KB Output is correct
11 Correct 41 ms 15304 KB Output is correct
12 Correct 10 ms 6232 KB Output is correct
13 Correct 22 ms 9820 KB Output is correct
14 Correct 1 ms 2392 KB Output is correct
15 Correct 1 ms 2652 KB Output is correct
16 Correct 75 ms 20804 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Incorrect 0 ms 2396 KB Tree @(3, 5) appears more than once: for edges on positions 0 and 1
19 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 0 ms 2396 KB Output is correct
8 Correct 0 ms 2396 KB Output is correct
9 Correct 81 ms 25284 KB Output is correct
10 Correct 7 ms 4940 KB Output is correct
11 Correct 41 ms 15304 KB Output is correct
12 Correct 10 ms 6232 KB Output is correct
13 Correct 22 ms 9820 KB Output is correct
14 Correct 1 ms 2392 KB Output is correct
15 Correct 1 ms 2652 KB Output is correct
16 Correct 75 ms 20804 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Incorrect 0 ms 2396 KB Tree @(3, 5) appears more than once: for edges on positions 0 and 1
19 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 0 ms 2396 KB Output is correct
8 Correct 0 ms 2396 KB Output is correct
9 Correct 81 ms 25284 KB Output is correct
10 Correct 7 ms 4940 KB Output is correct
11 Correct 41 ms 15304 KB Output is correct
12 Correct 10 ms 6232 KB Output is correct
13 Correct 22 ms 9820 KB Output is correct
14 Correct 1 ms 2392 KB Output is correct
15 Correct 1 ms 2652 KB Output is correct
16 Correct 75 ms 20804 KB Output is correct
17 Correct 1 ms 2392 KB Output is correct
18 Correct 0 ms 2396 KB Output is correct
19 Correct 0 ms 2396 KB Output is correct
20 Incorrect 211 ms 49596 KB Tree @(195231, 4773) appears more than once: for edges on positions 0 and 1
21 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 0 ms 2396 KB Output is correct
8 Correct 0 ms 2396 KB Output is correct
9 Correct 81 ms 25284 KB Output is correct
10 Correct 7 ms 4940 KB Output is correct
11 Correct 41 ms 15304 KB Output is correct
12 Correct 10 ms 6232 KB Output is correct
13 Correct 22 ms 9820 KB Output is correct
14 Correct 1 ms 2392 KB Output is correct
15 Correct 1 ms 2652 KB Output is correct
16 Correct 75 ms 20804 KB Output is correct
17 Incorrect 197 ms 49968 KB Tree @(100001, 3) appears more than once: for edges on positions 58789 and 58790
18 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 0 ms 2396 KB Output is correct
8 Correct 0 ms 2396 KB Output is correct
9 Correct 81 ms 25284 KB Output is correct
10 Correct 7 ms 4940 KB Output is correct
11 Correct 41 ms 15304 KB Output is correct
12 Correct 10 ms 6232 KB Output is correct
13 Correct 22 ms 9820 KB Output is correct
14 Correct 1 ms 2392 KB Output is correct
15 Correct 1 ms 2652 KB Output is correct
16 Correct 75 ms 20804 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Incorrect 0 ms 2396 KB Tree @(3, 5) appears more than once: for edges on positions 0 and 1
19 Halted 0 ms 0 KB -