#include <iostream>
#include <map>
#include <vector>
using namespace std;
#pragma warning (disable: 4996)
int N, T, X[1 << 18], Y[1 << 18];
map<pair<int, int>, int> Map;
vector<int> G[1 << 18], I;
bool used[1 << 18];
void dfs(int pos) {
used[pos] = true; I.push_back(pos);
for (int i : G[pos]) {
if (used[i] == false) dfs(i);
}
}
void solve_subtask1() {
for (int i = 1; i <= N; i++) Map[make_pair(X[i], Y[i])] = i;
for (int i = 1; i <= N; i++) {
int dx[8] = { 1, 1, 1, 0, -1, -1, -1, 0 };
int dy[8] = { -1, 0, 1, 1, 1, 0, -1, -1 };
for (int j = 0; j < 8; j++) {
int ex = X[i] + dx[j], ey = Y[i] + dy[j];
if (Map[make_pair(ex, ey)] >= 1) {
G[i].push_back(Map[make_pair(ex, ey)]);
}
}
}
dfs(1);
if ((int)I.size() != N) {
printf("NO\n");
}
else {
printf("YES\n");
for (int i = 0; i < I.size(); i++) printf("%d\n", I[i]);
}
}
void solve_subtask2() {
}
int main() {
scanf("%d%d", &N, &T);
for (int i = 1; i <= N; i++) scanf("%d%d", &X[i], &Y[i]);
if (T == 1) {
solve_subtask1();
}
else {
solve_subtask2();
}
return 0;
}
Compilation message
skyscrapers.cpp:5:0: warning: ignoring #pragma warning [-Wunknown-pragmas]
#pragma warning (disable: 4996)
skyscrapers.cpp: In function 'void solve_subtask1()':
skyscrapers.cpp:38:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = 0; i < I.size(); i++) printf("%d\n", I[i]);
~~^~~~~~~~~~
skyscrapers.cpp: In function 'int main()':
skyscrapers.cpp:47:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d", &N, &T);
~~~~~^~~~~~~~~~~~~~~~
skyscrapers.cpp:48:36: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
for (int i = 1; i <= N; i++) scanf("%d%d", &X[i], &Y[i]);
~~~~~^~~~~~~~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
6520 KB |
ans=YES N=1 |
2 |
Correct |
9 ms |
6520 KB |
ans=YES N=4 |
3 |
Correct |
9 ms |
6520 KB |
ans=NO N=4 |
4 |
Correct |
9 ms |
6392 KB |
ans=YES N=5 |
5 |
Correct |
8 ms |
6524 KB |
ans=YES N=9 |
6 |
Correct |
9 ms |
6520 KB |
ans=YES N=5 |
7 |
Correct |
8 ms |
6520 KB |
ans=NO N=9 |
8 |
Correct |
8 ms |
6520 KB |
ans=NO N=10 |
9 |
Correct |
8 ms |
6520 KB |
ans=YES N=10 |
10 |
Correct |
9 ms |
6392 KB |
ans=YES N=10 |
11 |
Correct |
8 ms |
6520 KB |
ans=YES N=10 |
12 |
Correct |
9 ms |
6520 KB |
ans=YES N=9 |
13 |
Correct |
9 ms |
6520 KB |
ans=YES N=9 |
14 |
Correct |
8 ms |
6520 KB |
ans=YES N=8 |
15 |
Correct |
9 ms |
6520 KB |
ans=YES N=8 |
16 |
Correct |
8 ms |
6520 KB |
ans=NO N=2 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
6520 KB |
ans=YES N=1 |
2 |
Correct |
9 ms |
6520 KB |
ans=YES N=4 |
3 |
Correct |
9 ms |
6520 KB |
ans=NO N=4 |
4 |
Correct |
9 ms |
6392 KB |
ans=YES N=5 |
5 |
Correct |
8 ms |
6524 KB |
ans=YES N=9 |
6 |
Correct |
9 ms |
6520 KB |
ans=YES N=5 |
7 |
Correct |
8 ms |
6520 KB |
ans=NO N=9 |
8 |
Correct |
8 ms |
6520 KB |
ans=NO N=10 |
9 |
Correct |
8 ms |
6520 KB |
ans=YES N=10 |
10 |
Correct |
9 ms |
6392 KB |
ans=YES N=10 |
11 |
Correct |
8 ms |
6520 KB |
ans=YES N=10 |
12 |
Correct |
9 ms |
6520 KB |
ans=YES N=9 |
13 |
Correct |
9 ms |
6520 KB |
ans=YES N=9 |
14 |
Correct |
8 ms |
6520 KB |
ans=YES N=8 |
15 |
Correct |
9 ms |
6520 KB |
ans=YES N=8 |
16 |
Correct |
8 ms |
6520 KB |
ans=NO N=2 |
17 |
Correct |
8 ms |
6524 KB |
ans=YES N=17 |
18 |
Incorrect |
9 ms |
6520 KB |
Added cell 25 (1,-1) not reachable from infinity |
19 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
6520 KB |
ans=YES N=1 |
2 |
Correct |
9 ms |
6520 KB |
ans=YES N=4 |
3 |
Correct |
9 ms |
6520 KB |
ans=NO N=4 |
4 |
Correct |
9 ms |
6392 KB |
ans=YES N=5 |
5 |
Correct |
8 ms |
6524 KB |
ans=YES N=9 |
6 |
Correct |
9 ms |
6520 KB |
ans=YES N=5 |
7 |
Correct |
8 ms |
6520 KB |
ans=NO N=9 |
8 |
Correct |
8 ms |
6520 KB |
ans=NO N=10 |
9 |
Correct |
8 ms |
6520 KB |
ans=YES N=10 |
10 |
Correct |
9 ms |
6392 KB |
ans=YES N=10 |
11 |
Correct |
8 ms |
6520 KB |
ans=YES N=10 |
12 |
Correct |
9 ms |
6520 KB |
ans=YES N=9 |
13 |
Correct |
9 ms |
6520 KB |
ans=YES N=9 |
14 |
Correct |
8 ms |
6520 KB |
ans=YES N=8 |
15 |
Correct |
9 ms |
6520 KB |
ans=YES N=8 |
16 |
Correct |
8 ms |
6520 KB |
ans=NO N=2 |
17 |
Correct |
8 ms |
6524 KB |
ans=YES N=17 |
18 |
Incorrect |
9 ms |
6520 KB |
Added cell 25 (1,-1) not reachable from infinity |
19 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
9 ms |
6520 KB |
Unexpected end of file - token expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
6520 KB |
ans=YES N=1 |
2 |
Correct |
9 ms |
6520 KB |
ans=YES N=4 |
3 |
Correct |
9 ms |
6520 KB |
ans=NO N=4 |
4 |
Correct |
9 ms |
6392 KB |
ans=YES N=5 |
5 |
Correct |
8 ms |
6524 KB |
ans=YES N=9 |
6 |
Correct |
9 ms |
6520 KB |
ans=YES N=5 |
7 |
Correct |
8 ms |
6520 KB |
ans=NO N=9 |
8 |
Correct |
8 ms |
6520 KB |
ans=NO N=10 |
9 |
Correct |
8 ms |
6520 KB |
ans=YES N=10 |
10 |
Correct |
9 ms |
6392 KB |
ans=YES N=10 |
11 |
Correct |
8 ms |
6520 KB |
ans=YES N=10 |
12 |
Correct |
9 ms |
6520 KB |
ans=YES N=9 |
13 |
Correct |
9 ms |
6520 KB |
ans=YES N=9 |
14 |
Correct |
8 ms |
6520 KB |
ans=YES N=8 |
15 |
Correct |
9 ms |
6520 KB |
ans=YES N=8 |
16 |
Correct |
8 ms |
6520 KB |
ans=NO N=2 |
17 |
Correct |
8 ms |
6524 KB |
ans=YES N=17 |
18 |
Incorrect |
9 ms |
6520 KB |
Added cell 25 (1,-1) not reachable from infinity |
19 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
25 ms |
7544 KB |
Unexpected end of file - token expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
9 ms |
6520 KB |
Unexpected end of file - token expected |
2 |
Halted |
0 ms |
0 KB |
- |