Submission #359296

# Submission time Handle Problem Language Result Execution time Memory
359296 2021-01-26T16:37:23 Z jesus_coconut Building Skyscrapers (CEOI19_skyscrapers) C++17
8 / 100
48 ms 4992 KB
#include <bits/stdc++.h>

using namespace std;
int n, t;
map<pair<int, int>, int> mp;

void read() {
	cin >> n;
	cin >> t;
	for (int i = 0; i < n; ++i) {
		int a, b;
		cin >> a >> b;
		mp[{a, b}] = i + 1;
	}
}

pair<int, int> dir[8] {
		{-1, -1},
		{-1, 0},
		{-1, 1},
		{0, -1},
		{0, 1},
		{1, -1},
		{1, 0},
		{1, 1}
};

void solve1() {
	int cnt = 0;
	queue<pair<int, int>> q;
	set<pair<int, int>> bio;
	vector<int> ans;
	q.emplace(mp.begin()->first);
	while (!q.empty()) {
		auto p = q.front();
		q.pop();
		++cnt;
		ans.push_back(mp[p]);
		bio.emplace(p);
		for (auto &[dx, dy] : dir) {
			auto np = p;
			np.first += dx;
			np.second += dy;
			if (!bio.count(np) && mp.count(np)) {
				q.emplace(np);
				bio.emplace(np);
			}
		}
	}
	if (cnt != n) cout << "NO\n";
	else {
		cout << "YES\n";
		for (auto a : ans) cout << a << '\n';
	}
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);

	read();
	if (t == 1) {
		solve1();
	}

	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB ans=YES N=1
2 Correct 1 ms 364 KB ans=YES N=4
3 Correct 1 ms 364 KB ans=NO N=4
4 Correct 1 ms 364 KB ans=YES N=5
5 Correct 1 ms 364 KB ans=YES N=9
6 Correct 1 ms 364 KB ans=YES N=5
7 Correct 1 ms 364 KB ans=NO N=9
8 Correct 1 ms 364 KB ans=NO N=10
9 Correct 1 ms 364 KB ans=YES N=10
10 Correct 1 ms 364 KB ans=YES N=10
11 Correct 1 ms 364 KB ans=YES N=10
12 Correct 1 ms 364 KB ans=YES N=9
13 Correct 1 ms 364 KB ans=YES N=9
14 Correct 1 ms 364 KB ans=YES N=8
15 Correct 1 ms 364 KB ans=YES N=8
16 Correct 1 ms 364 KB ans=NO N=2
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB ans=YES N=1
2 Correct 1 ms 364 KB ans=YES N=4
3 Correct 1 ms 364 KB ans=NO N=4
4 Correct 1 ms 364 KB ans=YES N=5
5 Correct 1 ms 364 KB ans=YES N=9
6 Correct 1 ms 364 KB ans=YES N=5
7 Correct 1 ms 364 KB ans=NO N=9
8 Correct 1 ms 364 KB ans=NO N=10
9 Correct 1 ms 364 KB ans=YES N=10
10 Correct 1 ms 364 KB ans=YES N=10
11 Correct 1 ms 364 KB ans=YES N=10
12 Correct 1 ms 364 KB ans=YES N=9
13 Correct 1 ms 364 KB ans=YES N=9
14 Correct 1 ms 364 KB ans=YES N=8
15 Correct 1 ms 364 KB ans=YES N=8
16 Correct 1 ms 364 KB ans=NO N=2
17 Correct 1 ms 364 KB ans=YES N=17
18 Correct 1 ms 396 KB ans=YES N=25
19 Correct 1 ms 364 KB ans=YES N=100
20 Correct 1 ms 384 KB ans=YES N=185
21 Correct 1 ms 364 KB ans=NO N=174
22 Correct 1 ms 364 KB ans=YES N=90
23 Correct 1 ms 364 KB ans=YES N=63
24 Correct 1 ms 364 KB ans=YES N=87
25 Correct 1 ms 364 KB ans=YES N=183
26 Correct 1 ms 384 KB ans=YES N=188
27 Correct 1 ms 364 KB ans=YES N=183
28 Correct 1 ms 364 KB ans=YES N=189
29 Correct 1 ms 364 KB ans=YES N=200
30 Correct 1 ms 376 KB ans=YES N=190
31 Correct 1 ms 236 KB ans=YES N=187
32 Correct 1 ms 364 KB ans=YES N=187
33 Correct 1 ms 364 KB ans=YES N=182
34 Correct 1 ms 384 KB ans=YES N=184
35 Correct 1 ms 364 KB ans=YES N=188
36 Correct 1 ms 364 KB ans=YES N=181
37 Correct 1 ms 364 KB ans=YES N=188
38 Correct 1 ms 364 KB ans=YES N=191
39 Incorrect 1 ms 364 KB Added cell 196 (16,2) not reachable from infinity
40 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB ans=YES N=1
2 Correct 1 ms 364 KB ans=YES N=4
3 Correct 1 ms 364 KB ans=NO N=4
4 Correct 1 ms 364 KB ans=YES N=5
5 Correct 1 ms 364 KB ans=YES N=9
6 Correct 1 ms 364 KB ans=YES N=5
7 Correct 1 ms 364 KB ans=NO N=9
8 Correct 1 ms 364 KB ans=NO N=10
9 Correct 1 ms 364 KB ans=YES N=10
10 Correct 1 ms 364 KB ans=YES N=10
11 Correct 1 ms 364 KB ans=YES N=10
12 Correct 1 ms 364 KB ans=YES N=9
13 Correct 1 ms 364 KB ans=YES N=9
14 Correct 1 ms 364 KB ans=YES N=8
15 Correct 1 ms 364 KB ans=YES N=8
16 Correct 1 ms 364 KB ans=NO N=2
17 Correct 1 ms 364 KB ans=YES N=17
18 Correct 1 ms 396 KB ans=YES N=25
19 Correct 1 ms 364 KB ans=YES N=100
20 Correct 1 ms 384 KB ans=YES N=185
21 Correct 1 ms 364 KB ans=NO N=174
22 Correct 1 ms 364 KB ans=YES N=90
23 Correct 1 ms 364 KB ans=YES N=63
24 Correct 1 ms 364 KB ans=YES N=87
25 Correct 1 ms 364 KB ans=YES N=183
26 Correct 1 ms 384 KB ans=YES N=188
27 Correct 1 ms 364 KB ans=YES N=183
28 Correct 1 ms 364 KB ans=YES N=189
29 Correct 1 ms 364 KB ans=YES N=200
30 Correct 1 ms 376 KB ans=YES N=190
31 Correct 1 ms 236 KB ans=YES N=187
32 Correct 1 ms 364 KB ans=YES N=187
33 Correct 1 ms 364 KB ans=YES N=182
34 Correct 1 ms 384 KB ans=YES N=184
35 Correct 1 ms 364 KB ans=YES N=188
36 Correct 1 ms 364 KB ans=YES N=181
37 Correct 1 ms 364 KB ans=YES N=188
38 Correct 1 ms 364 KB ans=YES N=191
39 Incorrect 1 ms 364 KB Added cell 196 (16,2) not reachable from infinity
40 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 492 KB Unexpected end of file - token expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB ans=YES N=1
2 Correct 1 ms 364 KB ans=YES N=4
3 Correct 1 ms 364 KB ans=NO N=4
4 Correct 1 ms 364 KB ans=YES N=5
5 Correct 1 ms 364 KB ans=YES N=9
6 Correct 1 ms 364 KB ans=YES N=5
7 Correct 1 ms 364 KB ans=NO N=9
8 Correct 1 ms 364 KB ans=NO N=10
9 Correct 1 ms 364 KB ans=YES N=10
10 Correct 1 ms 364 KB ans=YES N=10
11 Correct 1 ms 364 KB ans=YES N=10
12 Correct 1 ms 364 KB ans=YES N=9
13 Correct 1 ms 364 KB ans=YES N=9
14 Correct 1 ms 364 KB ans=YES N=8
15 Correct 1 ms 364 KB ans=YES N=8
16 Correct 1 ms 364 KB ans=NO N=2
17 Correct 1 ms 364 KB ans=YES N=17
18 Correct 1 ms 396 KB ans=YES N=25
19 Correct 1 ms 364 KB ans=YES N=100
20 Correct 1 ms 384 KB ans=YES N=185
21 Correct 1 ms 364 KB ans=NO N=174
22 Correct 1 ms 364 KB ans=YES N=90
23 Correct 1 ms 364 KB ans=YES N=63
24 Correct 1 ms 364 KB ans=YES N=87
25 Correct 1 ms 364 KB ans=YES N=183
26 Correct 1 ms 384 KB ans=YES N=188
27 Correct 1 ms 364 KB ans=YES N=183
28 Correct 1 ms 364 KB ans=YES N=189
29 Correct 1 ms 364 KB ans=YES N=200
30 Correct 1 ms 376 KB ans=YES N=190
31 Correct 1 ms 236 KB ans=YES N=187
32 Correct 1 ms 364 KB ans=YES N=187
33 Correct 1 ms 364 KB ans=YES N=182
34 Correct 1 ms 384 KB ans=YES N=184
35 Correct 1 ms 364 KB ans=YES N=188
36 Correct 1 ms 364 KB ans=YES N=181
37 Correct 1 ms 364 KB ans=YES N=188
38 Correct 1 ms 364 KB ans=YES N=191
39 Incorrect 1 ms 364 KB Added cell 196 (16,2) not reachable from infinity
40 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 48 ms 4992 KB Unexpected end of file - token expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 492 KB Unexpected end of file - token expected
2 Halted 0 ms 0 KB -