#pragma GCC optimize("O1,O2,O3,Ofast,unroll-loops")
#include <bits/stdc++.h>
#include <string>
#include <iostream>
#include <cmath>
#include <numeric>
#include <stack>
#include <queue>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ld, ld> pd;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<pi>> vvpi;
typedef vector<ld> vd;
typedef vector<long long> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
#define FOR(i, a, b) for (ll i = a; i < (b); i++)
#define F0R(i, a) for (int i = 0; i < (a); i++)
#define FORd(i, a, b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i, a) for (int i = (a)-1; i >= 0; i--)
#define trav(a, x) for (auto &a : x)
#define uid(a, b) uniform_int_distribution<int>(a, b)(rng)
#define len(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define F first
#define nl endl
#define S second
#define lb lower_bound
#define ub upper_bound
#define aint(x) x.begin(), x.end()
#define raint(x) x.rbegin(), x.rend()
#define ins insert
const int MOD = 1e6+3;
void init(string name)
{
freopen((name + ".in").c_str(), "r", stdin);
freopen((name + ".out").c_str(), "w", stdout);
}
void fastIO()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
}
vi tryx = {0,0,1,-1,-1,1,-1,1};
vi tryy = {1,-1,0,0,-1,-1,1,1};
void solve()
{
int n,t;cin >> n >> t;
map<pi,int> mp;
set<pair<pi,int>> arr;
FOR(i,0,n){
int a,b;cin >> a >> b;
if(i==0)arr.insert({{a,b},-1});
else mp[{a,b}] = i+1;
}
vi ans;
while(!arr.empty()){
auto edge = *arr.begin();
arr.erase(arr.begin());
ans.pb(-edge.S);
pi pos = edge.F;
FOR(i,0,8){
int x = pos.F + tryx[i], y = pos.S + tryy[i];
if(mp.count({x,y})){
arr.insert({{x,y},-mp[{x,y}]});
mp.erase({x,y});
}
}
}
if(ans.size() != n){cout << "NO\n";return;}
cout << "YES\n";
for(int a:ans)cout << a << "\n";
}
int main()
{
fastIO();
// init("test");
int t = 1;
// cin >> t;
while (t--)
solve();
return 0;
}
Compilation message
skyscrapers.cpp: In function 'void solve()':
skyscrapers.cpp:83:19: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
83 | if(ans.size() != n){cout << "NO\n";return;}
| ~~~~~~~~~~~^~~~
skyscrapers.cpp: In function 'void init(std::string)':
skyscrapers.cpp:44:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
44 | freopen((name + ".in").c_str(), "r", stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
skyscrapers.cpp:45:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
45 | freopen((name + ".out").c_str(), "w", stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
ans=YES N=1 |
2 |
Correct |
0 ms |
348 KB |
ans=YES N=4 |
3 |
Correct |
0 ms |
348 KB |
ans=NO N=4 |
4 |
Correct |
0 ms |
348 KB |
ans=YES N=5 |
5 |
Correct |
0 ms |
348 KB |
ans=YES N=9 |
6 |
Correct |
0 ms |
348 KB |
ans=YES N=5 |
7 |
Correct |
0 ms |
348 KB |
ans=NO N=9 |
8 |
Correct |
0 ms |
348 KB |
ans=NO N=10 |
9 |
Correct |
0 ms |
348 KB |
ans=YES N=10 |
10 |
Correct |
0 ms |
344 KB |
ans=YES N=10 |
11 |
Correct |
0 ms |
348 KB |
ans=YES N=10 |
12 |
Correct |
0 ms |
348 KB |
ans=YES N=9 |
13 |
Correct |
0 ms |
348 KB |
ans=YES N=9 |
14 |
Correct |
0 ms |
348 KB |
ans=YES N=8 |
15 |
Correct |
0 ms |
348 KB |
ans=YES N=8 |
16 |
Correct |
0 ms |
348 KB |
ans=NO N=2 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
ans=YES N=1 |
2 |
Correct |
0 ms |
348 KB |
ans=YES N=4 |
3 |
Correct |
0 ms |
348 KB |
ans=NO N=4 |
4 |
Correct |
0 ms |
348 KB |
ans=YES N=5 |
5 |
Correct |
0 ms |
348 KB |
ans=YES N=9 |
6 |
Correct |
0 ms |
348 KB |
ans=YES N=5 |
7 |
Correct |
0 ms |
348 KB |
ans=NO N=9 |
8 |
Correct |
0 ms |
348 KB |
ans=NO N=10 |
9 |
Correct |
0 ms |
348 KB |
ans=YES N=10 |
10 |
Correct |
0 ms |
344 KB |
ans=YES N=10 |
11 |
Correct |
0 ms |
348 KB |
ans=YES N=10 |
12 |
Correct |
0 ms |
348 KB |
ans=YES N=9 |
13 |
Correct |
0 ms |
348 KB |
ans=YES N=9 |
14 |
Correct |
0 ms |
348 KB |
ans=YES N=8 |
15 |
Correct |
0 ms |
348 KB |
ans=YES N=8 |
16 |
Correct |
0 ms |
348 KB |
ans=NO N=2 |
17 |
Correct |
0 ms |
348 KB |
ans=YES N=17 |
18 |
Correct |
0 ms |
348 KB |
ans=YES N=25 |
19 |
Correct |
0 ms |
348 KB |
ans=YES N=100 |
20 |
Correct |
0 ms |
348 KB |
ans=YES N=185 |
21 |
Correct |
1 ms |
348 KB |
ans=NO N=174 |
22 |
Correct |
0 ms |
348 KB |
ans=YES N=90 |
23 |
Correct |
0 ms |
348 KB |
ans=YES N=63 |
24 |
Correct |
0 ms |
348 KB |
ans=YES N=87 |
25 |
Correct |
0 ms |
348 KB |
ans=YES N=183 |
26 |
Correct |
0 ms |
348 KB |
ans=YES N=188 |
27 |
Correct |
1 ms |
348 KB |
ans=YES N=183 |
28 |
Correct |
0 ms |
348 KB |
ans=YES N=189 |
29 |
Correct |
1 ms |
348 KB |
ans=YES N=200 |
30 |
Correct |
1 ms |
348 KB |
ans=YES N=190 |
31 |
Correct |
1 ms |
348 KB |
ans=YES N=187 |
32 |
Correct |
0 ms |
452 KB |
ans=YES N=187 |
33 |
Correct |
1 ms |
348 KB |
ans=YES N=182 |
34 |
Correct |
0 ms |
348 KB |
ans=YES N=184 |
35 |
Correct |
0 ms |
348 KB |
ans=YES N=188 |
36 |
Correct |
0 ms |
348 KB |
ans=YES N=181 |
37 |
Correct |
0 ms |
348 KB |
ans=YES N=188 |
38 |
Correct |
1 ms |
348 KB |
ans=YES N=191 |
39 |
Correct |
0 ms |
348 KB |
ans=YES N=196 |
40 |
Correct |
0 ms |
360 KB |
ans=YES N=196 |
41 |
Correct |
0 ms |
348 KB |
ans=YES N=196 |
42 |
Correct |
0 ms |
348 KB |
ans=YES N=196 |
43 |
Correct |
1 ms |
348 KB |
ans=YES N=195 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
ans=YES N=1 |
2 |
Correct |
0 ms |
348 KB |
ans=YES N=4 |
3 |
Correct |
0 ms |
348 KB |
ans=NO N=4 |
4 |
Correct |
0 ms |
348 KB |
ans=YES N=5 |
5 |
Correct |
0 ms |
348 KB |
ans=YES N=9 |
6 |
Correct |
0 ms |
348 KB |
ans=YES N=5 |
7 |
Correct |
0 ms |
348 KB |
ans=NO N=9 |
8 |
Correct |
0 ms |
348 KB |
ans=NO N=10 |
9 |
Correct |
0 ms |
348 KB |
ans=YES N=10 |
10 |
Correct |
0 ms |
344 KB |
ans=YES N=10 |
11 |
Correct |
0 ms |
348 KB |
ans=YES N=10 |
12 |
Correct |
0 ms |
348 KB |
ans=YES N=9 |
13 |
Correct |
0 ms |
348 KB |
ans=YES N=9 |
14 |
Correct |
0 ms |
348 KB |
ans=YES N=8 |
15 |
Correct |
0 ms |
348 KB |
ans=YES N=8 |
16 |
Correct |
0 ms |
348 KB |
ans=NO N=2 |
17 |
Correct |
0 ms |
348 KB |
ans=YES N=17 |
18 |
Correct |
0 ms |
348 KB |
ans=YES N=25 |
19 |
Correct |
0 ms |
348 KB |
ans=YES N=100 |
20 |
Correct |
0 ms |
348 KB |
ans=YES N=185 |
21 |
Correct |
1 ms |
348 KB |
ans=NO N=174 |
22 |
Correct |
0 ms |
348 KB |
ans=YES N=90 |
23 |
Correct |
0 ms |
348 KB |
ans=YES N=63 |
24 |
Correct |
0 ms |
348 KB |
ans=YES N=87 |
25 |
Correct |
0 ms |
348 KB |
ans=YES N=183 |
26 |
Correct |
0 ms |
348 KB |
ans=YES N=188 |
27 |
Correct |
1 ms |
348 KB |
ans=YES N=183 |
28 |
Correct |
0 ms |
348 KB |
ans=YES N=189 |
29 |
Correct |
1 ms |
348 KB |
ans=YES N=200 |
30 |
Correct |
1 ms |
348 KB |
ans=YES N=190 |
31 |
Correct |
1 ms |
348 KB |
ans=YES N=187 |
32 |
Correct |
0 ms |
452 KB |
ans=YES N=187 |
33 |
Correct |
1 ms |
348 KB |
ans=YES N=182 |
34 |
Correct |
0 ms |
348 KB |
ans=YES N=184 |
35 |
Correct |
0 ms |
348 KB |
ans=YES N=188 |
36 |
Correct |
0 ms |
348 KB |
ans=YES N=181 |
37 |
Correct |
0 ms |
348 KB |
ans=YES N=188 |
38 |
Correct |
1 ms |
348 KB |
ans=YES N=191 |
39 |
Correct |
0 ms |
348 KB |
ans=YES N=196 |
40 |
Correct |
0 ms |
360 KB |
ans=YES N=196 |
41 |
Correct |
0 ms |
348 KB |
ans=YES N=196 |
42 |
Correct |
0 ms |
348 KB |
ans=YES N=196 |
43 |
Correct |
1 ms |
348 KB |
ans=YES N=195 |
44 |
Correct |
2 ms |
604 KB |
ans=NO N=1934 |
45 |
Correct |
1 ms |
348 KB |
ans=NO N=1965 |
46 |
Correct |
1 ms |
604 KB |
ans=YES N=1824 |
47 |
Correct |
1 ms |
604 KB |
ans=YES N=1981 |
48 |
Correct |
1 ms |
604 KB |
ans=YES N=1814 |
49 |
Correct |
2 ms |
604 KB |
ans=YES N=1854 |
50 |
Correct |
1 ms |
472 KB |
ans=YES N=1831 |
51 |
Correct |
2 ms |
604 KB |
ans=YES N=2000 |
52 |
Correct |
2 ms |
604 KB |
ans=YES N=1847 |
53 |
Correct |
1 ms |
604 KB |
ans=YES N=1819 |
54 |
Correct |
2 ms |
604 KB |
ans=YES N=1986 |
55 |
Correct |
2 ms |
464 KB |
ans=YES N=2000 |
56 |
Correct |
2 ms |
604 KB |
ans=YES N=1834 |
57 |
Correct |
2 ms |
604 KB |
ans=YES N=1860 |
58 |
Correct |
2 ms |
604 KB |
ans=YES N=1898 |
59 |
Correct |
2 ms |
604 KB |
ans=YES N=1832 |
60 |
Correct |
2 ms |
620 KB |
ans=YES N=1929 |
61 |
Correct |
2 ms |
620 KB |
ans=YES N=1919 |
62 |
Correct |
2 ms |
604 KB |
ans=YES N=1882 |
63 |
Correct |
2 ms |
604 KB |
ans=YES N=1922 |
64 |
Correct |
2 ms |
604 KB |
ans=YES N=1989 |
65 |
Correct |
1 ms |
604 KB |
ans=YES N=1978 |
66 |
Correct |
2 ms |
604 KB |
ans=YES N=1867 |
67 |
Correct |
2 ms |
604 KB |
ans=YES N=1942 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
ans=NO N=1934 |
2 |
Correct |
1 ms |
348 KB |
ans=NO N=1965 |
3 |
Incorrect |
1 ms |
348 KB |
Contestant's solution is not lexicographically largest at index 1824 (1813 vs 1702) |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
ans=YES N=1 |
2 |
Correct |
0 ms |
348 KB |
ans=YES N=4 |
3 |
Correct |
0 ms |
348 KB |
ans=NO N=4 |
4 |
Correct |
0 ms |
348 KB |
ans=YES N=5 |
5 |
Correct |
0 ms |
348 KB |
ans=YES N=9 |
6 |
Correct |
0 ms |
348 KB |
ans=YES N=5 |
7 |
Correct |
0 ms |
348 KB |
ans=NO N=9 |
8 |
Correct |
0 ms |
348 KB |
ans=NO N=10 |
9 |
Correct |
0 ms |
348 KB |
ans=YES N=10 |
10 |
Correct |
0 ms |
344 KB |
ans=YES N=10 |
11 |
Correct |
0 ms |
348 KB |
ans=YES N=10 |
12 |
Correct |
0 ms |
348 KB |
ans=YES N=9 |
13 |
Correct |
0 ms |
348 KB |
ans=YES N=9 |
14 |
Correct |
0 ms |
348 KB |
ans=YES N=8 |
15 |
Correct |
0 ms |
348 KB |
ans=YES N=8 |
16 |
Correct |
0 ms |
348 KB |
ans=NO N=2 |
17 |
Correct |
0 ms |
348 KB |
ans=YES N=17 |
18 |
Correct |
0 ms |
348 KB |
ans=YES N=25 |
19 |
Correct |
0 ms |
348 KB |
ans=YES N=100 |
20 |
Correct |
0 ms |
348 KB |
ans=YES N=185 |
21 |
Correct |
1 ms |
348 KB |
ans=NO N=174 |
22 |
Correct |
0 ms |
348 KB |
ans=YES N=90 |
23 |
Correct |
0 ms |
348 KB |
ans=YES N=63 |
24 |
Correct |
0 ms |
348 KB |
ans=YES N=87 |
25 |
Correct |
0 ms |
348 KB |
ans=YES N=183 |
26 |
Correct |
0 ms |
348 KB |
ans=YES N=188 |
27 |
Correct |
1 ms |
348 KB |
ans=YES N=183 |
28 |
Correct |
0 ms |
348 KB |
ans=YES N=189 |
29 |
Correct |
1 ms |
348 KB |
ans=YES N=200 |
30 |
Correct |
1 ms |
348 KB |
ans=YES N=190 |
31 |
Correct |
1 ms |
348 KB |
ans=YES N=187 |
32 |
Correct |
0 ms |
452 KB |
ans=YES N=187 |
33 |
Correct |
1 ms |
348 KB |
ans=YES N=182 |
34 |
Correct |
0 ms |
348 KB |
ans=YES N=184 |
35 |
Correct |
0 ms |
348 KB |
ans=YES N=188 |
36 |
Correct |
0 ms |
348 KB |
ans=YES N=181 |
37 |
Correct |
0 ms |
348 KB |
ans=YES N=188 |
38 |
Correct |
1 ms |
348 KB |
ans=YES N=191 |
39 |
Correct |
0 ms |
348 KB |
ans=YES N=196 |
40 |
Correct |
0 ms |
360 KB |
ans=YES N=196 |
41 |
Correct |
0 ms |
348 KB |
ans=YES N=196 |
42 |
Correct |
0 ms |
348 KB |
ans=YES N=196 |
43 |
Correct |
1 ms |
348 KB |
ans=YES N=195 |
44 |
Correct |
2 ms |
604 KB |
ans=NO N=1934 |
45 |
Correct |
1 ms |
348 KB |
ans=NO N=1965 |
46 |
Correct |
1 ms |
604 KB |
ans=YES N=1824 |
47 |
Correct |
1 ms |
604 KB |
ans=YES N=1981 |
48 |
Correct |
1 ms |
604 KB |
ans=YES N=1814 |
49 |
Correct |
2 ms |
604 KB |
ans=YES N=1854 |
50 |
Correct |
1 ms |
472 KB |
ans=YES N=1831 |
51 |
Correct |
2 ms |
604 KB |
ans=YES N=2000 |
52 |
Correct |
2 ms |
604 KB |
ans=YES N=1847 |
53 |
Correct |
1 ms |
604 KB |
ans=YES N=1819 |
54 |
Correct |
2 ms |
604 KB |
ans=YES N=1986 |
55 |
Correct |
2 ms |
464 KB |
ans=YES N=2000 |
56 |
Correct |
2 ms |
604 KB |
ans=YES N=1834 |
57 |
Correct |
2 ms |
604 KB |
ans=YES N=1860 |
58 |
Correct |
2 ms |
604 KB |
ans=YES N=1898 |
59 |
Correct |
2 ms |
604 KB |
ans=YES N=1832 |
60 |
Correct |
2 ms |
620 KB |
ans=YES N=1929 |
61 |
Correct |
2 ms |
620 KB |
ans=YES N=1919 |
62 |
Correct |
2 ms |
604 KB |
ans=YES N=1882 |
63 |
Correct |
2 ms |
604 KB |
ans=YES N=1922 |
64 |
Correct |
2 ms |
604 KB |
ans=YES N=1989 |
65 |
Correct |
1 ms |
604 KB |
ans=YES N=1978 |
66 |
Correct |
2 ms |
604 KB |
ans=YES N=1867 |
67 |
Correct |
2 ms |
604 KB |
ans=YES N=1942 |
68 |
Correct |
52 ms |
5680 KB |
ans=NO N=66151 |
69 |
Correct |
25 ms |
4840 KB |
ans=NO N=64333 |
70 |
Correct |
49 ms |
6100 KB |
ans=YES N=69316 |
71 |
Correct |
48 ms |
5920 KB |
ans=YES N=66695 |
72 |
Correct |
49 ms |
6092 KB |
ans=YES N=68436 |
73 |
Correct |
51 ms |
6096 KB |
ans=YES N=70000 |
74 |
Correct |
55 ms |
5972 KB |
ans=YES N=68501 |
75 |
Correct |
49 ms |
6196 KB |
ans=YES N=70000 |
76 |
Correct |
46 ms |
5844 KB |
ans=YES N=65009 |
77 |
Correct |
58 ms |
5840 KB |
ans=YES N=67007 |
78 |
Correct |
59 ms |
5836 KB |
ans=YES N=66357 |
79 |
Correct |
56 ms |
5848 KB |
ans=YES N=65430 |
80 |
Correct |
58 ms |
5736 KB |
ans=YES N=65790 |
81 |
Correct |
61 ms |
5836 KB |
ans=YES N=66020 |
82 |
Correct |
54 ms |
5844 KB |
ans=YES N=65809 |
83 |
Correct |
51 ms |
5848 KB |
ans=YES N=65651 |
84 |
Correct |
63 ms |
6048 KB |
ans=YES N=68040 |
85 |
Correct |
60 ms |
5836 KB |
ans=YES N=66570 |
86 |
Correct |
46 ms |
5592 KB |
ans=YES N=65421 |
87 |
Correct |
51 ms |
6092 KB |
ans=YES N=68351 |
88 |
Correct |
48 ms |
5836 KB |
ans=YES N=67027 |
89 |
Correct |
50 ms |
6092 KB |
ans=YES N=68879 |
90 |
Correct |
47 ms |
5980 KB |
ans=YES N=67256 |
91 |
Correct |
114 ms |
12368 KB |
ans=YES N=148315 |
92 |
Correct |
57 ms |
10580 KB |
ans=NO N=142745 |
93 |
Correct |
67 ms |
12628 KB |
ans=NO N=148443 |
94 |
Correct |
123 ms |
14284 KB |
ans=YES N=148328 |
95 |
Correct |
123 ms |
14288 KB |
ans=YES N=147855 |
96 |
Correct |
123 ms |
14540 KB |
ans=YES N=150000 |
97 |
Correct |
130 ms |
14000 KB |
ans=YES N=144725 |
98 |
Correct |
132 ms |
14312 KB |
ans=YES N=149445 |
99 |
Correct |
125 ms |
14028 KB |
ans=YES N=144455 |
100 |
Correct |
127 ms |
13776 KB |
ans=YES N=143487 |
101 |
Correct |
144 ms |
14284 KB |
ans=YES N=149688 |
102 |
Correct |
134 ms |
13772 KB |
ans=YES N=141481 |
103 |
Correct |
143 ms |
14132 KB |
ans=YES N=147430 |
104 |
Correct |
129 ms |
13768 KB |
ans=YES N=142247 |
105 |
Correct |
138 ms |
14540 KB |
ans=YES N=149941 |
106 |
Correct |
137 ms |
13824 KB |
ans=YES N=141635 |
107 |
Correct |
141 ms |
13652 KB |
ans=YES N=142896 |
108 |
Correct |
144 ms |
13512 KB |
ans=YES N=142069 |
109 |
Correct |
118 ms |
13172 KB |
ans=YES N=142378 |
110 |
Correct |
141 ms |
14536 KB |
ans=YES N=150000 |
111 |
Correct |
128 ms |
13496 KB |
ans=YES N=141452 |
112 |
Correct |
108 ms |
13004 KB |
ans=YES N=134453 |
113 |
Correct |
108 ms |
13680 KB |
ans=YES N=144172 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
48 ms |
5072 KB |
ans=NO N=66151 |
2 |
Correct |
26 ms |
4444 KB |
ans=NO N=64333 |
3 |
Incorrect |
50 ms |
5588 KB |
Contestant's solution is not lexicographically largest at index 69316 (69235 vs 7320) |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
ans=NO N=1934 |
2 |
Correct |
1 ms |
348 KB |
ans=NO N=1965 |
3 |
Incorrect |
1 ms |
348 KB |
Contestant's solution is not lexicographically largest at index 1824 (1813 vs 1702) |
4 |
Halted |
0 ms |
0 KB |
- |