답안 #564855

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
564855 2022-05-19T19:58:27 Z birthdaycake Building Skyscrapers (CEOI19_skyscrapers) C++17
0 / 100
85 ms 10620 KB
#include<bits/stdc++.h>
#define int long long
#define endl '\n'
#define mod 1000000007
#define boost ios_base::sync_with_stdio(false), cin.tie(NULL);
using namespace std;
 
 
 
 
int xx[] = {-1,-1,-1,0,1,1,1,0}, yy[] = {-1,0,1,1,1,0,-1,-1};

signed main(){
    boost;
    
    
    int n,t; cin >> n >> t;
    
    vector<pair<int,pair<int,int>>>d(n);
    vector<int>ans;
    map<pair<int,int>,int>o;
    for(int i = 0; i < n; i++){
        cin >> d[i].first >> d[i].second.first;
        d[i].second.second = i + 1;
        o[{d[i].first,d[i].second.first}] = i + 1;
    }
    int x = -1e18, y = -1e18, j = 0;
    set<pair<int,pair<int,int>>>c;
    set<pair<int,int>>a;
    for(int i = 0; i < n; i++){
        if(d[i].first > x){
            x = d[i].first;
            y = d[i].second.first;
            j = i + 1;
            
        }else if(d[i].first == x && d[i].second.first > y){
            x = d[i].first;
            y = d[i].second.first;
            j = i + 1;
        }
        a.insert({d[i].first,d[i].second.first});
    }
    a.erase({x,y});
    c.insert({x,{y,j}});
    while(c.size()){
        auto f = *c.begin();
        ans.push_back(f.second.second);
        c.erase(c.begin());
        for(int i = 0; i < 8; i++){
            int aa = f.first + xx[i], b = f.second.first + yy[i];
            if(aa < 0 || b < 0 || aa > 1e9 || b > 1e9 || !a.count({aa,b})) continue;
            c.insert({aa,{b,o[{aa,b}]}});
            a.erase({aa,b});
        }
    }
    if(ans.size() < n){
        cout << "NO";
        return 0;
    }
    cout << "YES" << endl;
    for(int i = 0; i < n ;i++){
        cout << ans[i] << endl;
    }
    
    
    
    
    return 0;
}

Compilation message

skyscrapers.cpp: In function 'int main()':
skyscrapers.cpp:56:19: 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]
   56 |     if(ans.size() < n){
      |        ~~~~~~~~~~~^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB ans=YES N=1
2 Correct 0 ms 212 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 212 KB ans=YES N=1
2 Correct 0 ms 212 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 212 KB ans=YES N=1
2 Correct 0 ms 212 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 596 KB ans=NO N=1934
2 Correct 2 ms 596 KB ans=NO N=1965
3 Incorrect 2 ms 596 KB Contestant's solution is not lexicographically largest at index 1824 (1813 vs 280)
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB ans=YES N=1
2 Correct 0 ms 212 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 73 ms 10488 KB ans=NO N=66151
2 Correct 66 ms 9824 KB ans=NO N=64333
3 Incorrect 85 ms 10620 KB Contestant did not find solution
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 596 KB ans=NO N=1934
2 Correct 2 ms 596 KB ans=NO N=1965
3 Incorrect 2 ms 596 KB Contestant's solution is not lexicographically largest at index 1824 (1813 vs 280)
4 Halted 0 ms 0 KB -