/* Author : Mychecksdead */
#include<bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;
typedef long double ld;
#define MOD1 (1000000000+7)
#define MOD (998244353)
#define PI 3.1415926535
#define pb push_back
#define setp() cout << setprecision(15)
#define all(x) x.begin(), x.end()
#define debug(x) cerr << #x << " is " << x << '\n';
const int N = 1e6+100, M = 1e5+10, F = 2147483646, K = 20;
int n, t, b[8][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}, {1, 1}, {1, -1}, {-1, 1}, {-1, -1}};
map<pair<int, int>, int> m, visited;
pair<int, int> a[N];
void solve(){
cin >> n >> t;
for(int i = 0; i < n; ++i){
cin >> a[i].first >> a[i].second;
m[a[i]] = i;
}
queue<pair<int, int>> q;
visited[a[0]] = 1;
q.push(a[0]);
vector<int> ans;
while(!q.empty()){
auto v = q.front(); q.pop();
ans.pb(m[v]);
for(int i = 0; i < 8; ++i){
int x = v.first + b[i][0];
int y = v.second + b[i][1];
if(!visited[{x, y}] && m[{x, y}] > 0){
q.push({x, y});
visited[{x, y}] = 1;
}
}
}
if(ans.size() == n){
cout << "YES\n";
for(int k: ans) cout << k + 1 << '\n';
}else cout << "NO";
}
int main(){
cin.tie(0); ios::sync_with_stdio(0);
int T = 1, aa;
// cin >> T;aa=T;
while(T--){
// cout << "Case #" << aa-T << ": ";
solve();
cout << '\n';
}
return 0;
}
Compilation message
skyscrapers.cpp: In function 'void solve()':
skyscrapers.cpp:42:19: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
42 | if(ans.size() == n){
| ~~~~~~~~~~~^~~~
skyscrapers.cpp: In function 'int main()':
skyscrapers.cpp:54:16: warning: unused variable 'aa' [-Wunused-variable]
54 | int T = 1, aa;
| ^~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
ans=YES N=1 |
2 |
Correct |
0 ms |
212 KB |
ans=YES N=4 |
3 |
Correct |
1 ms |
212 KB |
ans=NO N=4 |
4 |
Correct |
0 ms |
212 KB |
ans=YES N=5 |
5 |
Correct |
1 ms |
328 KB |
ans=YES N=9 |
6 |
Correct |
1 ms |
432 KB |
ans=YES N=5 |
7 |
Correct |
1 ms |
212 KB |
ans=NO N=9 |
8 |
Correct |
0 ms |
212 KB |
ans=NO N=10 |
9 |
Correct |
0 ms |
212 KB |
ans=YES N=10 |
10 |
Correct |
0 ms |
332 KB |
ans=YES N=10 |
11 |
Correct |
0 ms |
340 KB |
ans=YES N=10 |
12 |
Correct |
0 ms |
212 KB |
ans=YES N=9 |
13 |
Correct |
0 ms |
212 KB |
ans=YES N=9 |
14 |
Correct |
0 ms |
212 KB |
ans=YES N=8 |
15 |
Correct |
0 ms |
340 KB |
ans=YES N=8 |
16 |
Correct |
0 ms |
212 KB |
ans=NO N=2 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
ans=YES N=1 |
2 |
Correct |
0 ms |
212 KB |
ans=YES N=4 |
3 |
Correct |
1 ms |
212 KB |
ans=NO N=4 |
4 |
Correct |
0 ms |
212 KB |
ans=YES N=5 |
5 |
Correct |
1 ms |
328 KB |
ans=YES N=9 |
6 |
Correct |
1 ms |
432 KB |
ans=YES N=5 |
7 |
Correct |
1 ms |
212 KB |
ans=NO N=9 |
8 |
Correct |
0 ms |
212 KB |
ans=NO N=10 |
9 |
Correct |
0 ms |
212 KB |
ans=YES N=10 |
10 |
Correct |
0 ms |
332 KB |
ans=YES N=10 |
11 |
Correct |
0 ms |
340 KB |
ans=YES N=10 |
12 |
Correct |
0 ms |
212 KB |
ans=YES N=9 |
13 |
Correct |
0 ms |
212 KB |
ans=YES N=9 |
14 |
Correct |
0 ms |
212 KB |
ans=YES N=8 |
15 |
Correct |
0 ms |
340 KB |
ans=YES N=8 |
16 |
Correct |
0 ms |
212 KB |
ans=NO N=2 |
17 |
Correct |
0 ms |
340 KB |
ans=YES N=17 |
18 |
Correct |
1 ms |
212 KB |
ans=YES N=25 |
19 |
Correct |
1 ms |
340 KB |
ans=YES N=100 |
20 |
Correct |
1 ms |
332 KB |
ans=YES N=185 |
21 |
Correct |
0 ms |
328 KB |
ans=NO N=174 |
22 |
Correct |
0 ms |
340 KB |
ans=YES N=90 |
23 |
Correct |
1 ms |
340 KB |
ans=YES N=63 |
24 |
Correct |
1 ms |
340 KB |
ans=YES N=87 |
25 |
Correct |
1 ms |
340 KB |
ans=YES N=183 |
26 |
Correct |
1 ms |
340 KB |
ans=YES N=188 |
27 |
Correct |
1 ms |
340 KB |
ans=YES N=183 |
28 |
Correct |
1 ms |
340 KB |
ans=YES N=189 |
29 |
Correct |
1 ms |
340 KB |
ans=YES N=200 |
30 |
Correct |
1 ms |
328 KB |
ans=YES N=190 |
31 |
Correct |
1 ms |
340 KB |
ans=YES N=187 |
32 |
Correct |
1 ms |
340 KB |
ans=YES N=187 |
33 |
Correct |
1 ms |
340 KB |
ans=YES N=182 |
34 |
Correct |
1 ms |
340 KB |
ans=YES N=184 |
35 |
Correct |
1 ms |
340 KB |
ans=YES N=188 |
36 |
Correct |
1 ms |
332 KB |
ans=YES N=181 |
37 |
Correct |
1 ms |
340 KB |
ans=YES N=188 |
38 |
Correct |
1 ms |
332 KB |
ans=YES N=191 |
39 |
Incorrect |
1 ms |
340 KB |
Added cell 196 (16,2) not reachable from infinity |
40 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
ans=YES N=1 |
2 |
Correct |
0 ms |
212 KB |
ans=YES N=4 |
3 |
Correct |
1 ms |
212 KB |
ans=NO N=4 |
4 |
Correct |
0 ms |
212 KB |
ans=YES N=5 |
5 |
Correct |
1 ms |
328 KB |
ans=YES N=9 |
6 |
Correct |
1 ms |
432 KB |
ans=YES N=5 |
7 |
Correct |
1 ms |
212 KB |
ans=NO N=9 |
8 |
Correct |
0 ms |
212 KB |
ans=NO N=10 |
9 |
Correct |
0 ms |
212 KB |
ans=YES N=10 |
10 |
Correct |
0 ms |
332 KB |
ans=YES N=10 |
11 |
Correct |
0 ms |
340 KB |
ans=YES N=10 |
12 |
Correct |
0 ms |
212 KB |
ans=YES N=9 |
13 |
Correct |
0 ms |
212 KB |
ans=YES N=9 |
14 |
Correct |
0 ms |
212 KB |
ans=YES N=8 |
15 |
Correct |
0 ms |
340 KB |
ans=YES N=8 |
16 |
Correct |
0 ms |
212 KB |
ans=NO N=2 |
17 |
Correct |
0 ms |
340 KB |
ans=YES N=17 |
18 |
Correct |
1 ms |
212 KB |
ans=YES N=25 |
19 |
Correct |
1 ms |
340 KB |
ans=YES N=100 |
20 |
Correct |
1 ms |
332 KB |
ans=YES N=185 |
21 |
Correct |
0 ms |
328 KB |
ans=NO N=174 |
22 |
Correct |
0 ms |
340 KB |
ans=YES N=90 |
23 |
Correct |
1 ms |
340 KB |
ans=YES N=63 |
24 |
Correct |
1 ms |
340 KB |
ans=YES N=87 |
25 |
Correct |
1 ms |
340 KB |
ans=YES N=183 |
26 |
Correct |
1 ms |
340 KB |
ans=YES N=188 |
27 |
Correct |
1 ms |
340 KB |
ans=YES N=183 |
28 |
Correct |
1 ms |
340 KB |
ans=YES N=189 |
29 |
Correct |
1 ms |
340 KB |
ans=YES N=200 |
30 |
Correct |
1 ms |
328 KB |
ans=YES N=190 |
31 |
Correct |
1 ms |
340 KB |
ans=YES N=187 |
32 |
Correct |
1 ms |
340 KB |
ans=YES N=187 |
33 |
Correct |
1 ms |
340 KB |
ans=YES N=182 |
34 |
Correct |
1 ms |
340 KB |
ans=YES N=184 |
35 |
Correct |
1 ms |
340 KB |
ans=YES N=188 |
36 |
Correct |
1 ms |
332 KB |
ans=YES N=181 |
37 |
Correct |
1 ms |
340 KB |
ans=YES N=188 |
38 |
Correct |
1 ms |
332 KB |
ans=YES N=191 |
39 |
Incorrect |
1 ms |
340 KB |
Added cell 196 (16,2) not reachable from infinity |
40 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
468 KB |
ans=NO N=1934 |
2 |
Correct |
2 ms |
468 KB |
ans=NO N=1965 |
3 |
Incorrect |
3 ms |
596 KB |
Contestant's solution is not lexicographically largest at index 1824 (1813 vs 595) |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
ans=YES N=1 |
2 |
Correct |
0 ms |
212 KB |
ans=YES N=4 |
3 |
Correct |
1 ms |
212 KB |
ans=NO N=4 |
4 |
Correct |
0 ms |
212 KB |
ans=YES N=5 |
5 |
Correct |
1 ms |
328 KB |
ans=YES N=9 |
6 |
Correct |
1 ms |
432 KB |
ans=YES N=5 |
7 |
Correct |
1 ms |
212 KB |
ans=NO N=9 |
8 |
Correct |
0 ms |
212 KB |
ans=NO N=10 |
9 |
Correct |
0 ms |
212 KB |
ans=YES N=10 |
10 |
Correct |
0 ms |
332 KB |
ans=YES N=10 |
11 |
Correct |
0 ms |
340 KB |
ans=YES N=10 |
12 |
Correct |
0 ms |
212 KB |
ans=YES N=9 |
13 |
Correct |
0 ms |
212 KB |
ans=YES N=9 |
14 |
Correct |
0 ms |
212 KB |
ans=YES N=8 |
15 |
Correct |
0 ms |
340 KB |
ans=YES N=8 |
16 |
Correct |
0 ms |
212 KB |
ans=NO N=2 |
17 |
Correct |
0 ms |
340 KB |
ans=YES N=17 |
18 |
Correct |
1 ms |
212 KB |
ans=YES N=25 |
19 |
Correct |
1 ms |
340 KB |
ans=YES N=100 |
20 |
Correct |
1 ms |
332 KB |
ans=YES N=185 |
21 |
Correct |
0 ms |
328 KB |
ans=NO N=174 |
22 |
Correct |
0 ms |
340 KB |
ans=YES N=90 |
23 |
Correct |
1 ms |
340 KB |
ans=YES N=63 |
24 |
Correct |
1 ms |
340 KB |
ans=YES N=87 |
25 |
Correct |
1 ms |
340 KB |
ans=YES N=183 |
26 |
Correct |
1 ms |
340 KB |
ans=YES N=188 |
27 |
Correct |
1 ms |
340 KB |
ans=YES N=183 |
28 |
Correct |
1 ms |
340 KB |
ans=YES N=189 |
29 |
Correct |
1 ms |
340 KB |
ans=YES N=200 |
30 |
Correct |
1 ms |
328 KB |
ans=YES N=190 |
31 |
Correct |
1 ms |
340 KB |
ans=YES N=187 |
32 |
Correct |
1 ms |
340 KB |
ans=YES N=187 |
33 |
Correct |
1 ms |
340 KB |
ans=YES N=182 |
34 |
Correct |
1 ms |
340 KB |
ans=YES N=184 |
35 |
Correct |
1 ms |
340 KB |
ans=YES N=188 |
36 |
Correct |
1 ms |
332 KB |
ans=YES N=181 |
37 |
Correct |
1 ms |
340 KB |
ans=YES N=188 |
38 |
Correct |
1 ms |
332 KB |
ans=YES N=191 |
39 |
Incorrect |
1 ms |
340 KB |
Added cell 196 (16,2) not reachable from infinity |
40 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
169 ms |
14824 KB |
ans=NO N=66151 |
2 |
Correct |
30 ms |
5296 KB |
ans=NO N=64333 |
3 |
Incorrect |
151 ms |
10952 KB |
Contestant's solution is not lexicographically largest at index 69316 (69235 vs 13970) |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
468 KB |
ans=NO N=1934 |
2 |
Correct |
2 ms |
468 KB |
ans=NO N=1965 |
3 |
Incorrect |
3 ms |
596 KB |
Contestant's solution is not lexicographically largest at index 1824 (1813 vs 595) |
4 |
Halted |
0 ms |
0 KB |
- |