답안 #564853

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
564853 2022-05-19T19:38:08 Z RealSnake Building Skyscrapers (CEOI19_skyscrapers) C++14
0 / 100
58 ms 6456 KB
#include "bits/stdc++.h"
using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

#define ll long long
#define mod 1000000007

ofstream fout(".out");
ifstream fin(".in");

ll n, t;
ll a[150001];
bool vis[150001];
map<pair<ll, ll>, ll> mp;
ll xi[8] = {-1, -1, -1, 0, 0, 1, 1, 1};
ll yi[8] = {-1, 0, 1, -1, 1, -1, 0, 1};

bool check(ll x, ll y) {
    return x >= 0 && x < n && y >= 0 && y < n;
}

signed main() {

    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    cin >> n >> t;
    vector<pair<ll, ll>> v;
    for(ll i = 0; i < n; i++) {
        ll x, y;
        cin >> x >> y;
        v.push_back({x, y});
        mp[{x, y}] = i + 1;
    }
    pair<ll, ll> p = *max_element(v.begin(), v.end());
    priority_queue<pair<ll, ll>> pq;
    pq.push(p);
    vis[mp[p] - 1] = 1;
    ll j = 0;
    while(!pq.empty()) {
        ll x = pq.top().first, y = pq.top().second;
        pq.pop();
        a[j++] = mp[{x, y}];
        for(ll i = 0; i < 8; i++) {
            ll xx = x + xi[i];
            ll yy = y + yi[i];
            if(check(xx, yy) && mp[{xx, yy}] && !vis[mp[{xx, yy}] - 1]) {
                vis[mp[{xx, yy}] - 1] = 1;
                pq.push({xx, yy});
            }
        }
    }
    if(j != n) {
        cout << "NO";
        return 0;
    }
    cout << "YES\n";
    for(ll i = 0; i < n; i++)
        cout << a[i] << "\n";

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB ans=YES N=1
2 Correct 1 ms 340 KB ans=YES N=4
3 Correct 1 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 1 ms 340 KB ans=YES N=4
3 Correct 1 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 1 ms 340 KB ans=YES N=4
3 Correct 1 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 1 ms 468 KB ans=NO N=1934
2 Correct 1 ms 468 KB ans=NO N=1965
3 Incorrect 3 ms 468 KB Contestant's solution is not lexicographically largest at index 1824 (1813 vs 974)
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB ans=YES N=1
2 Correct 1 ms 340 KB ans=YES N=4
3 Correct 1 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 58 ms 6456 KB ans=NO N=66151
2 Correct 50 ms 5300 KB ans=NO N=64333
3 Incorrect 36 ms 6456 KB Contestant did not find solution
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 3 ms 468 KB Contestant's solution is not lexicographically largest at index 1824 (1813 vs 974)
4 Halted 0 ms 0 KB -