답안 #446285

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
446285 2021-07-21T13:13:55 Z benedict0724 Building Skyscrapers (CEOI19_skyscrapers) C++17
54 / 100
721 ms 92476 KB
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

map<pair<int, int>, int> m;
struct node
{
    int x, y, i;
    node() : node(0, 0, 0) {}
    node(int _x, int _y, int _i) : x(_x), y(_y), i(_i) {}
    bool operator < (const node &O) const
    {
        if(x == O.x) return y > O.y;
        return x > O.x;
    }
} Sky[150002];

int dx[8] = {1, 1, 1, 0, 0, -1, -1, -1};
int dy[8] = {1, 0, -1, 1, -1, 1, 0, -1};
vector<int> adj[150002];
int X[150002], Y[150002];
bool visited[150002];
queue<int> q;
priority_queue<node> pq;
void bfs(int x)
{
    visited[x] = true;
    pq.push(node(X[x], Y[x], x));
    while(!pq.empty())
    {
        int now = pq.top().i;
        q.push(now);
        pq.pop();
        for(int i : adj[now])
        {
            if(visited[i]) continue;
            visited[i] = true;
            pq.push(node(X[i], Y[i], i));
        }
    }
}

int main()
{
    ios::sync_with_stdio(false); cin.tie(NULL);
    int n, t; cin >> n >> t;
    for(int i=1;i<=n;i++)
    {
        int x, y; cin >> x >> y;
        X[i] = x, Y[i] = y;
        Sky[i] = node(x, y, i);
        m[{x, y}] = i;
        for(int j=0;j<8;j++)
        {
            int tmp = m[{x + dx[j], y+dy[j]}];
            if(tmp == 0) continue;
            adj[tmp].push_back(i);
            adj[i].push_back(tmp);
        }
    }

    sort(Sky + 1, Sky + n + 1);
    bfs(Sky[n].i);

    if(q.size() < n) cout << "NO\n";
    else
    {
        cout << "YES\n";
        while(!q.empty())
        {
            cout << q.front() << "\n";
            q.pop();
        }
    }
}

Compilation message

skyscrapers.cpp: In function 'int main()':
skyscrapers.cpp:66:17: warning: comparison of integer expressions of different signedness: 'std::queue<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   66 |     if(q.size() < n) cout << "NO\n";
      |        ~~~~~~~~~^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 5580 KB ans=YES N=1
2 Correct 4 ms 5580 KB ans=YES N=4
3 Correct 4 ms 5580 KB ans=NO N=4
4 Correct 4 ms 5580 KB ans=YES N=5
5 Correct 4 ms 5580 KB ans=YES N=9
6 Correct 4 ms 5536 KB ans=YES N=5
7 Correct 4 ms 5600 KB ans=NO N=9
8 Correct 4 ms 5604 KB ans=NO N=10
9 Correct 4 ms 5580 KB ans=YES N=10
10 Correct 4 ms 5600 KB ans=YES N=10
11 Correct 4 ms 5580 KB ans=YES N=10
12 Correct 4 ms 5580 KB ans=YES N=9
13 Correct 4 ms 5580 KB ans=YES N=9
14 Correct 4 ms 5516 KB ans=YES N=8
15 Correct 4 ms 5708 KB ans=YES N=8
16 Correct 4 ms 5604 KB ans=NO N=2
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 5580 KB ans=YES N=1
2 Correct 4 ms 5580 KB ans=YES N=4
3 Correct 4 ms 5580 KB ans=NO N=4
4 Correct 4 ms 5580 KB ans=YES N=5
5 Correct 4 ms 5580 KB ans=YES N=9
6 Correct 4 ms 5536 KB ans=YES N=5
7 Correct 4 ms 5600 KB ans=NO N=9
8 Correct 4 ms 5604 KB ans=NO N=10
9 Correct 4 ms 5580 KB ans=YES N=10
10 Correct 4 ms 5600 KB ans=YES N=10
11 Correct 4 ms 5580 KB ans=YES N=10
12 Correct 4 ms 5580 KB ans=YES N=9
13 Correct 4 ms 5580 KB ans=YES N=9
14 Correct 4 ms 5516 KB ans=YES N=8
15 Correct 4 ms 5708 KB ans=YES N=8
16 Correct 4 ms 5604 KB ans=NO N=2
17 Correct 4 ms 5580 KB ans=YES N=17
18 Correct 4 ms 5580 KB ans=YES N=25
19 Correct 4 ms 5580 KB ans=YES N=100
20 Correct 5 ms 5580 KB ans=YES N=185
21 Correct 4 ms 5608 KB ans=NO N=174
22 Correct 4 ms 5580 KB ans=YES N=90
23 Correct 4 ms 5580 KB ans=YES N=63
24 Correct 4 ms 5580 KB ans=YES N=87
25 Correct 4 ms 5564 KB ans=YES N=183
26 Correct 4 ms 5580 KB ans=YES N=188
27 Correct 4 ms 5580 KB ans=YES N=183
28 Correct 4 ms 5580 KB ans=YES N=189
29 Correct 4 ms 5580 KB ans=YES N=200
30 Correct 4 ms 5580 KB ans=YES N=190
31 Correct 4 ms 5580 KB ans=YES N=187
32 Correct 4 ms 5608 KB ans=YES N=187
33 Correct 4 ms 5580 KB ans=YES N=182
34 Correct 4 ms 5580 KB ans=YES N=184
35 Correct 4 ms 5580 KB ans=YES N=188
36 Correct 4 ms 5580 KB ans=YES N=181
37 Correct 4 ms 5580 KB ans=YES N=188
38 Correct 4 ms 5604 KB ans=YES N=191
39 Correct 4 ms 5580 KB ans=YES N=196
40 Correct 4 ms 5580 KB ans=YES N=196
41 Correct 4 ms 5580 KB ans=YES N=196
42 Correct 4 ms 5580 KB ans=YES N=196
43 Correct 4 ms 5580 KB ans=YES N=195
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 5580 KB ans=YES N=1
2 Correct 4 ms 5580 KB ans=YES N=4
3 Correct 4 ms 5580 KB ans=NO N=4
4 Correct 4 ms 5580 KB ans=YES N=5
5 Correct 4 ms 5580 KB ans=YES N=9
6 Correct 4 ms 5536 KB ans=YES N=5
7 Correct 4 ms 5600 KB ans=NO N=9
8 Correct 4 ms 5604 KB ans=NO N=10
9 Correct 4 ms 5580 KB ans=YES N=10
10 Correct 4 ms 5600 KB ans=YES N=10
11 Correct 4 ms 5580 KB ans=YES N=10
12 Correct 4 ms 5580 KB ans=YES N=9
13 Correct 4 ms 5580 KB ans=YES N=9
14 Correct 4 ms 5516 KB ans=YES N=8
15 Correct 4 ms 5708 KB ans=YES N=8
16 Correct 4 ms 5604 KB ans=NO N=2
17 Correct 4 ms 5580 KB ans=YES N=17
18 Correct 4 ms 5580 KB ans=YES N=25
19 Correct 4 ms 5580 KB ans=YES N=100
20 Correct 5 ms 5580 KB ans=YES N=185
21 Correct 4 ms 5608 KB ans=NO N=174
22 Correct 4 ms 5580 KB ans=YES N=90
23 Correct 4 ms 5580 KB ans=YES N=63
24 Correct 4 ms 5580 KB ans=YES N=87
25 Correct 4 ms 5564 KB ans=YES N=183
26 Correct 4 ms 5580 KB ans=YES N=188
27 Correct 4 ms 5580 KB ans=YES N=183
28 Correct 4 ms 5580 KB ans=YES N=189
29 Correct 4 ms 5580 KB ans=YES N=200
30 Correct 4 ms 5580 KB ans=YES N=190
31 Correct 4 ms 5580 KB ans=YES N=187
32 Correct 4 ms 5608 KB ans=YES N=187
33 Correct 4 ms 5580 KB ans=YES N=182
34 Correct 4 ms 5580 KB ans=YES N=184
35 Correct 4 ms 5580 KB ans=YES N=188
36 Correct 4 ms 5580 KB ans=YES N=181
37 Correct 4 ms 5580 KB ans=YES N=188
38 Correct 4 ms 5604 KB ans=YES N=191
39 Correct 4 ms 5580 KB ans=YES N=196
40 Correct 4 ms 5580 KB ans=YES N=196
41 Correct 4 ms 5580 KB ans=YES N=196
42 Correct 4 ms 5580 KB ans=YES N=196
43 Correct 4 ms 5580 KB ans=YES N=195
44 Correct 8 ms 6732 KB ans=NO N=1934
45 Correct 8 ms 5972 KB ans=NO N=1965
46 Correct 9 ms 5868 KB ans=YES N=1824
47 Correct 8 ms 5836 KB ans=YES N=1981
48 Correct 7 ms 5836 KB ans=YES N=1814
49 Correct 7 ms 5868 KB ans=YES N=1854
50 Correct 7 ms 5836 KB ans=YES N=1831
51 Correct 8 ms 5868 KB ans=YES N=2000
52 Correct 8 ms 5964 KB ans=YES N=1847
53 Correct 7 ms 5964 KB ans=YES N=1819
54 Correct 7 ms 5836 KB ans=YES N=1986
55 Correct 8 ms 6092 KB ans=YES N=2000
56 Correct 8 ms 6092 KB ans=YES N=1834
57 Correct 8 ms 6092 KB ans=YES N=1860
58 Correct 8 ms 6092 KB ans=YES N=1898
59 Correct 9 ms 5964 KB ans=YES N=1832
60 Correct 10 ms 6128 KB ans=YES N=1929
61 Correct 7 ms 5964 KB ans=YES N=1919
62 Correct 8 ms 5964 KB ans=YES N=1882
63 Correct 8 ms 6132 KB ans=YES N=1922
64 Correct 9 ms 6008 KB ans=YES N=1989
65 Correct 7 ms 5924 KB ans=YES N=1978
66 Correct 7 ms 5964 KB ans=YES N=1867
67 Correct 8 ms 5964 KB ans=YES N=1942
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 6732 KB ans=NO N=1934
2 Correct 7 ms 6004 KB ans=NO N=1965
3 Incorrect 7 ms 5836 KB Contestant's solution is not lexicographically largest at index 1824 (1813 vs 1702)
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 5580 KB ans=YES N=1
2 Correct 4 ms 5580 KB ans=YES N=4
3 Correct 4 ms 5580 KB ans=NO N=4
4 Correct 4 ms 5580 KB ans=YES N=5
5 Correct 4 ms 5580 KB ans=YES N=9
6 Correct 4 ms 5536 KB ans=YES N=5
7 Correct 4 ms 5600 KB ans=NO N=9
8 Correct 4 ms 5604 KB ans=NO N=10
9 Correct 4 ms 5580 KB ans=YES N=10
10 Correct 4 ms 5600 KB ans=YES N=10
11 Correct 4 ms 5580 KB ans=YES N=10
12 Correct 4 ms 5580 KB ans=YES N=9
13 Correct 4 ms 5580 KB ans=YES N=9
14 Correct 4 ms 5516 KB ans=YES N=8
15 Correct 4 ms 5708 KB ans=YES N=8
16 Correct 4 ms 5604 KB ans=NO N=2
17 Correct 4 ms 5580 KB ans=YES N=17
18 Correct 4 ms 5580 KB ans=YES N=25
19 Correct 4 ms 5580 KB ans=YES N=100
20 Correct 5 ms 5580 KB ans=YES N=185
21 Correct 4 ms 5608 KB ans=NO N=174
22 Correct 4 ms 5580 KB ans=YES N=90
23 Correct 4 ms 5580 KB ans=YES N=63
24 Correct 4 ms 5580 KB ans=YES N=87
25 Correct 4 ms 5564 KB ans=YES N=183
26 Correct 4 ms 5580 KB ans=YES N=188
27 Correct 4 ms 5580 KB ans=YES N=183
28 Correct 4 ms 5580 KB ans=YES N=189
29 Correct 4 ms 5580 KB ans=YES N=200
30 Correct 4 ms 5580 KB ans=YES N=190
31 Correct 4 ms 5580 KB ans=YES N=187
32 Correct 4 ms 5608 KB ans=YES N=187
33 Correct 4 ms 5580 KB ans=YES N=182
34 Correct 4 ms 5580 KB ans=YES N=184
35 Correct 4 ms 5580 KB ans=YES N=188
36 Correct 4 ms 5580 KB ans=YES N=181
37 Correct 4 ms 5580 KB ans=YES N=188
38 Correct 4 ms 5604 KB ans=YES N=191
39 Correct 4 ms 5580 KB ans=YES N=196
40 Correct 4 ms 5580 KB ans=YES N=196
41 Correct 4 ms 5580 KB ans=YES N=196
42 Correct 4 ms 5580 KB ans=YES N=196
43 Correct 4 ms 5580 KB ans=YES N=195
44 Correct 8 ms 6732 KB ans=NO N=1934
45 Correct 8 ms 5972 KB ans=NO N=1965
46 Correct 9 ms 5868 KB ans=YES N=1824
47 Correct 8 ms 5836 KB ans=YES N=1981
48 Correct 7 ms 5836 KB ans=YES N=1814
49 Correct 7 ms 5868 KB ans=YES N=1854
50 Correct 7 ms 5836 KB ans=YES N=1831
51 Correct 8 ms 5868 KB ans=YES N=2000
52 Correct 8 ms 5964 KB ans=YES N=1847
53 Correct 7 ms 5964 KB ans=YES N=1819
54 Correct 7 ms 5836 KB ans=YES N=1986
55 Correct 8 ms 6092 KB ans=YES N=2000
56 Correct 8 ms 6092 KB ans=YES N=1834
57 Correct 8 ms 6092 KB ans=YES N=1860
58 Correct 8 ms 6092 KB ans=YES N=1898
59 Correct 9 ms 5964 KB ans=YES N=1832
60 Correct 10 ms 6128 KB ans=YES N=1929
61 Correct 7 ms 5964 KB ans=YES N=1919
62 Correct 8 ms 5964 KB ans=YES N=1882
63 Correct 8 ms 6132 KB ans=YES N=1922
64 Correct 9 ms 6008 KB ans=YES N=1989
65 Correct 7 ms 5924 KB ans=YES N=1978
66 Correct 7 ms 5964 KB ans=YES N=1867
67 Correct 8 ms 5964 KB ans=YES N=1942
68 Correct 262 ms 16452 KB ans=NO N=66151
69 Correct 280 ms 35596 KB ans=NO N=64333
70 Correct 258 ms 15600 KB ans=YES N=69316
71 Correct 249 ms 15044 KB ans=YES N=66695
72 Correct 247 ms 15444 KB ans=YES N=68436
73 Correct 233 ms 15744 KB ans=YES N=70000
74 Correct 224 ms 15584 KB ans=YES N=68501
75 Correct 232 ms 15936 KB ans=YES N=70000
76 Correct 221 ms 16120 KB ans=YES N=65009
77 Correct 264 ms 19512 KB ans=YES N=67007
78 Correct 250 ms 21144 KB ans=YES N=66357
79 Correct 296 ms 22712 KB ans=YES N=65430
80 Correct 269 ms 22260 KB ans=YES N=65790
81 Correct 275 ms 21112 KB ans=YES N=66020
82 Correct 274 ms 20228 KB ans=YES N=65809
83 Correct 255 ms 17092 KB ans=YES N=65651
84 Correct 286 ms 26508 KB ans=YES N=68040
85 Correct 297 ms 24368 KB ans=YES N=66570
86 Correct 214 ms 15564 KB ans=YES N=65421
87 Correct 267 ms 16500 KB ans=YES N=68351
88 Correct 222 ms 15032 KB ans=YES N=67027
89 Correct 257 ms 18304 KB ans=YES N=68879
90 Correct 238 ms 16232 KB ans=YES N=67256
91 Correct 660 ms 27364 KB ans=YES N=148315
92 Correct 703 ms 78980 KB ans=NO N=142745
93 Correct 551 ms 92476 KB ans=NO N=148443
94 Correct 657 ms 27516 KB ans=YES N=148328
95 Correct 656 ms 27460 KB ans=YES N=147855
96 Correct 692 ms 27828 KB ans=YES N=150000
97 Correct 659 ms 27008 KB ans=YES N=144725
98 Correct 677 ms 27768 KB ans=YES N=149445
99 Correct 647 ms 27232 KB ans=YES N=144455
100 Correct 633 ms 26948 KB ans=YES N=143487
101 Correct 651 ms 27996 KB ans=YES N=149688
102 Correct 654 ms 36584 KB ans=YES N=141481
103 Correct 672 ms 47720 KB ans=YES N=147430
104 Correct 654 ms 31432 KB ans=YES N=142247
105 Correct 702 ms 35856 KB ans=YES N=149941
106 Correct 626 ms 45344 KB ans=YES N=141635
107 Correct 668 ms 42336 KB ans=YES N=142896
108 Correct 695 ms 46072 KB ans=YES N=142069
109 Correct 640 ms 29568 KB ans=YES N=142378
110 Correct 721 ms 40196 KB ans=YES N=150000
111 Correct 692 ms 51636 KB ans=YES N=141452
112 Correct 580 ms 49604 KB ans=YES N=134453
113 Correct 561 ms 51520 KB ans=YES N=144172
# 결과 실행 시간 메모리 Grader output
1 Correct 208 ms 16456 KB ans=NO N=66151
2 Correct 269 ms 35652 KB ans=NO N=64333
3 Incorrect 258 ms 15460 KB Contestant's solution is not lexicographically largest at index 69316 (69235 vs 7320)
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 6732 KB ans=NO N=1934
2 Correct 7 ms 6004 KB ans=NO N=1965
3 Incorrect 7 ms 5836 KB Contestant's solution is not lexicographically largest at index 1824 (1813 vs 1702)
4 Halted 0 ms 0 KB -