답안 #564839

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
564839 2022-05-19T19:00:24 Z 1zaid1 Building Skyscrapers (CEOI19_skyscrapers) C++17
8 / 100
111 ms 9316 KB
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define int long long
typedef long long ll;
const int M = 2e6 + 5, MOD = 1e9+7;
struct point {int x, y, i;};
bool operator<(point a, point b) {if (a.x == b.x) return a.y < b.y; return a.x < b.x;}
vector<pair<int, int>> st = {{-1, -1}, {0, -1}, {1, -1}, {1, 0}, {1, 1}, {0, 1}, {-1, 1}, {-1, 0}};

signed main() {
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    srand(time(0));
    
    int n, t, ind = 0;
    cin >> n >> t;

    vector<int> ans;
    map<int, int> ok;
    vector<point> v(n);
    for (auto&i:v) cin >> i.x >> i.y;
    for (auto&[x, y, i]:v) i = ++ind;
    for (auto [x, y, i]:v) ok[x*2e9+y] = i;
    priority_queue<point> q;
    q.push(*min_element(v.begin(), v.end()));
    ok[min_element(v.begin(), v.end())->x*2e9+min_element(v.begin(), v.end())->y] = 0;
    while (!q.empty()) {
        ans.push_back(q.top().i);
        auto [x, y, k] = q.top(); q.pop();
        for (auto [i, j]:st) {
            if (ok[(x+i)*2e9+(y+j)]) {
                q.push({x+i, y+j, ok[(x+i)*2e9+(y+j)]});
                ok[(x+i)*2e9+(y+j)] = 0;
            }
        }
    }

    if (ans.size() == n) {
        cout << "YES" << endl;
        for (int i:ans) cout << i << endl;
    } else cout << "NO" << endl;

    return 0;
}

/*
3 2
0 0
0 1
0 2
*/

Compilation message

skyscrapers.cpp: In function 'int main()':
skyscrapers.cpp:38:20: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   38 |     if (ans.size() == n) {
      |         ~~~~~~~~~~~^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB ans=YES N=1
2 Correct 1 ms 212 KB ans=YES N=4
3 Correct 0 ms 212 KB ans=NO N=4
4 Correct 0 ms 212 KB ans=YES N=5
5 Correct 0 ms 212 KB ans=YES N=9
6 Correct 0 ms 212 KB ans=YES N=5
7 Correct 0 ms 212 KB ans=NO N=9
8 Correct 0 ms 212 KB ans=NO N=10
9 Correct 1 ms 212 KB ans=YES N=10
10 Correct 1 ms 212 KB ans=YES N=10
11 Correct 1 ms 212 KB ans=YES N=10
12 Correct 1 ms 212 KB ans=YES N=9
13 Correct 1 ms 320 KB ans=YES N=9
14 Correct 1 ms 212 KB ans=YES N=8
15 Correct 1 ms 320 KB ans=YES N=8
16 Correct 1 ms 212 KB ans=NO N=2
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB ans=YES N=1
2 Correct 1 ms 212 KB ans=YES N=4
3 Correct 0 ms 212 KB ans=NO N=4
4 Correct 0 ms 212 KB ans=YES N=5
5 Correct 0 ms 212 KB ans=YES N=9
6 Correct 0 ms 212 KB ans=YES N=5
7 Correct 0 ms 212 KB ans=NO N=9
8 Correct 0 ms 212 KB ans=NO N=10
9 Correct 1 ms 212 KB ans=YES N=10
10 Correct 1 ms 212 KB ans=YES N=10
11 Correct 1 ms 212 KB ans=YES N=10
12 Correct 1 ms 212 KB ans=YES N=9
13 Correct 1 ms 320 KB ans=YES N=9
14 Correct 1 ms 212 KB ans=YES N=8
15 Correct 1 ms 320 KB ans=YES N=8
16 Correct 1 ms 212 KB ans=NO N=2
17 Correct 1 ms 212 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 340 KB ans=YES N=185
21 Correct 1 ms 324 KB ans=NO N=174
22 Correct 1 ms 212 KB ans=YES N=90
23 Correct 1 ms 212 KB ans=YES N=63
24 Correct 1 ms 340 KB ans=YES N=87
25 Correct 1 ms 320 KB ans=YES N=183
26 Incorrect 1 ms 212 KB Contestant did not find solution
27 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB ans=YES N=1
2 Correct 1 ms 212 KB ans=YES N=4
3 Correct 0 ms 212 KB ans=NO N=4
4 Correct 0 ms 212 KB ans=YES N=5
5 Correct 0 ms 212 KB ans=YES N=9
6 Correct 0 ms 212 KB ans=YES N=5
7 Correct 0 ms 212 KB ans=NO N=9
8 Correct 0 ms 212 KB ans=NO N=10
9 Correct 1 ms 212 KB ans=YES N=10
10 Correct 1 ms 212 KB ans=YES N=10
11 Correct 1 ms 212 KB ans=YES N=10
12 Correct 1 ms 212 KB ans=YES N=9
13 Correct 1 ms 320 KB ans=YES N=9
14 Correct 1 ms 212 KB ans=YES N=8
15 Correct 1 ms 320 KB ans=YES N=8
16 Correct 1 ms 212 KB ans=NO N=2
17 Correct 1 ms 212 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 340 KB ans=YES N=185
21 Correct 1 ms 324 KB ans=NO N=174
22 Correct 1 ms 212 KB ans=YES N=90
23 Correct 1 ms 212 KB ans=YES N=63
24 Correct 1 ms 340 KB ans=YES N=87
25 Correct 1 ms 320 KB ans=YES N=183
26 Incorrect 1 ms 212 KB Contestant did not find solution
27 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 468 KB ans=NO N=1934
2 Correct 1 ms 468 KB ans=NO N=1965
3 Incorrect 2 ms 468 KB Contestant's solution is not lexicographically largest at index 1824 (1813 vs 585)
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB ans=YES N=1
2 Correct 1 ms 212 KB ans=YES N=4
3 Correct 0 ms 212 KB ans=NO N=4
4 Correct 0 ms 212 KB ans=YES N=5
5 Correct 0 ms 212 KB ans=YES N=9
6 Correct 0 ms 212 KB ans=YES N=5
7 Correct 0 ms 212 KB ans=NO N=9
8 Correct 0 ms 212 KB ans=NO N=10
9 Correct 1 ms 212 KB ans=YES N=10
10 Correct 1 ms 212 KB ans=YES N=10
11 Correct 1 ms 212 KB ans=YES N=10
12 Correct 1 ms 212 KB ans=YES N=9
13 Correct 1 ms 320 KB ans=YES N=9
14 Correct 1 ms 212 KB ans=YES N=8
15 Correct 1 ms 320 KB ans=YES N=8
16 Correct 1 ms 212 KB ans=NO N=2
17 Correct 1 ms 212 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 340 KB ans=YES N=185
21 Correct 1 ms 324 KB ans=NO N=174
22 Correct 1 ms 212 KB ans=YES N=90
23 Correct 1 ms 212 KB ans=YES N=63
24 Correct 1 ms 340 KB ans=YES N=87
25 Correct 1 ms 320 KB ans=YES N=183
26 Incorrect 1 ms 212 KB Contestant did not find solution
27 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 111 ms 9316 KB ans=NO N=66151
2 Correct 30 ms 5808 KB ans=NO N=64333
3 Incorrect 101 ms 7420 KB Contestant's solution is not lexicographically largest at index 69316 (69235 vs 2522)
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 468 KB ans=NO N=1934
2 Correct 1 ms 468 KB ans=NO N=1965
3 Incorrect 2 ms 468 KB Contestant's solution is not lexicographically largest at index 1824 (1813 vs 585)
4 Halted 0 ms 0 KB -