답안 #598829

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
598829 2022-07-19T06:13:27 Z 이동현(#8460) Building Skyscrapers (CEOI19_skyscrapers) C++17
0 / 100
182 ms 6484 KB
#include <bits/stdc++.h>

using namespace std;

int wx[8] = {-1, -1, 0, 1, 1, 1, 0, -1}, wy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main(){
    int n, t; cin >> n >> t;
    vector<pair<int, int>> a(n);
    map<int, map<int, int>> mp;
    vector<int> chk(n);
    vector<int> ans;
    vector<int> mn = {(int)2e9, (int)2e9};
    for(int i = 0; i < n; ++i){
        cin >> a[i].first >> a[i].second;
        mp[a[i].first][a[i].second] = i;
        mn = min(mn, vector<int>{a[i].first, a[i].second, i});
    }
    priority_queue<vector<int>> pq;
    pq.push(mn);
    while(!pq.empty()){
        auto top = pq.top(); pq.pop();
        if(chk[top[2]]){
            continue;
        }
        chk[top[2]] = 1;
        ans.push_back(top[2]);
        mp[top[0]][top[1]] -= top[2];
        for(int i = 0; i < 8; ++i){
            int nx = top[0] + wx[i], ny = top[1] + wy[i];
            if(mp[nx][ny]){
                pq.push({nx, ny, mp[nx][ny]});
            }
        }
    }
    if((int)ans.size() != n){
        cout << "NO\n";
    }
    else{
        cout << "YES\n";
        for(auto&i:ans){
            cout << i + 1 << '\n';
        }
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB ans=YES N=1
2 Correct 0 ms 212 KB ans=YES N=4
3 Correct 0 ms 212 KB ans=NO N=4
4 Incorrect 0 ms 212 KB Contestant did not find solution
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB ans=YES N=1
2 Correct 0 ms 212 KB ans=YES N=4
3 Correct 0 ms 212 KB ans=NO N=4
4 Incorrect 0 ms 212 KB Contestant did not find solution
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB ans=YES N=1
2 Correct 0 ms 212 KB ans=YES N=4
3 Correct 0 ms 212 KB ans=NO N=4
4 Incorrect 0 ms 212 KB Contestant did not find solution
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 596 KB ans=NO N=1934
2 Correct 2 ms 340 KB ans=NO N=1965
3 Incorrect 4 ms 340 KB Contestant did not find solution
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB ans=YES N=1
2 Correct 0 ms 212 KB ans=YES N=4
3 Correct 0 ms 212 KB ans=NO N=4
4 Incorrect 0 ms 212 KB Contestant did not find solution
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 158 ms 6484 KB ans=NO N=66151
2 Correct 50 ms 4128 KB ans=NO N=64333
3 Incorrect 182 ms 5148 KB Contestant did not find solution
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 596 KB ans=NO N=1934
2 Correct 2 ms 340 KB ans=NO N=1965
3 Incorrect 4 ms 340 KB Contestant did not find solution
4 Halted 0 ms 0 KB -