답안 #564726

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
564726 2022-05-19T14:09:42 Z MrDeboo Building Skyscrapers (CEOI19_skyscrapers) C++17
8 / 100
146 ms 33568 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define int long long
#define endl '\n'
using namespace std;
using namespace __gnu_pbds;
using ordered_set = tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>;
vector<int>g;
map<pair<int,int>,int>mp;
map<pair<int,int>,bool>vis;
signed main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n,t;
    cin>>n>>t;
    pair<int,int>pr[n];
    for(int i=0;i<n;i++){
        cin>>pr[i].first>>pr[i].second;
        mp[pr[i]]=i+1;
    }
    sort(pr,pr+n);
    deque<pair<int,int>>dq={pr[0]};
    vis[pr[0]]=1;
    int x[]={0,0,1,1,1};
    int y[]={-1,1,-1,0,1};
    while(dq.size()){
        pair<int,int>p=dq.front();
        dq.pop_front();
        g.push_back(mp[p]);
        for(int i=0;i<5;i++){
            pair<int,int>pp={p.first+x[i],p.second+y[i]};
            if(!vis[pp]&&mp[pp]){
                vis[pp]=1;
                dq.push_back(pp);
            }
        }
    }
    int X[]={1,1,1,0,0,-1,-1,-1};
    int Y[]={-1,0,1,-1,1,1,-1,0};
    for(int i=n-1;i>=0;i--){
        if(vis[pr[i]])continue;
        bool bl=0;
        for(int w=0;w<8;w++){
            if(vis[{X[w]+pr[i].first,Y[w]+pr[i].second}])bl=1;
        }
        if(!bl)continue;
        dq.push_back(pr[i]);
        vis[pr[i]]=1;
        while(dq.size()){
            pair<int,int>p=dq.front();
            dq.pop_front();
            g.push_back(mp[p]);
            for(int w=0;w<5;w++){
                pair<int,int>pp={p.first+x[w],p.second+y[w]};
                if(!vis[pp]&&mp[pp]){
                    vis[pp]=1;
                    dq.push_back(pp);
                }
            }
        }
    }
    if(g.size()!=n){cout<<"NO";}
    else{
        cout<<"YES\n";
        for(auto &i:g)cout<<i<<endl;
    }
}

Compilation message

skyscrapers.cpp: In function 'int main()':
skyscrapers.cpp:62:16: 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]
   62 |     if(g.size()!=n){cout<<"NO";}
      |        ~~~~~~~~^~~
# 결과 실행 시간 메모리 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 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 0 ms 212 KB ans=YES N=10
10 Correct 0 ms 212 KB ans=YES N=10
11 Correct 0 ms 212 KB ans=YES N=10
12 Correct 0 ms 212 KB ans=YES N=9
13 Correct 0 ms 212 KB ans=YES N=9
14 Correct 1 ms 212 KB ans=YES N=8
15 Correct 1 ms 212 KB ans=YES N=8
16 Correct 0 ms 212 KB ans=NO N=2
# 결과 실행 시간 메모리 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 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 0 ms 212 KB ans=YES N=10
10 Correct 0 ms 212 KB ans=YES N=10
11 Correct 0 ms 212 KB ans=YES N=10
12 Correct 0 ms 212 KB ans=YES N=9
13 Correct 0 ms 212 KB ans=YES N=9
14 Correct 1 ms 212 KB ans=YES N=8
15 Correct 1 ms 212 KB ans=YES N=8
16 Correct 0 ms 212 KB ans=NO N=2
17 Correct 0 ms 212 KB ans=YES N=17
18 Incorrect 1 ms 212 KB Added cell 25 (-1,1) not reachable from infinity
19 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 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 0 ms 212 KB ans=YES N=10
10 Correct 0 ms 212 KB ans=YES N=10
11 Correct 0 ms 212 KB ans=YES N=10
12 Correct 0 ms 212 KB ans=YES N=9
13 Correct 0 ms 212 KB ans=YES N=9
14 Correct 1 ms 212 KB ans=YES N=8
15 Correct 1 ms 212 KB ans=YES N=8
16 Correct 0 ms 212 KB ans=NO N=2
17 Correct 0 ms 212 KB ans=YES N=17
18 Incorrect 1 ms 212 KB Added cell 25 (-1,1) not reachable from infinity
19 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 1492 KB ans=NO N=1934
2 Correct 3 ms 724 KB ans=NO N=1965
3 Incorrect 3 ms 596 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 0 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 0 ms 212 KB ans=YES N=10
10 Correct 0 ms 212 KB ans=YES N=10
11 Correct 0 ms 212 KB ans=YES N=10
12 Correct 0 ms 212 KB ans=YES N=9
13 Correct 0 ms 212 KB ans=YES N=9
14 Correct 1 ms 212 KB ans=YES N=8
15 Correct 1 ms 212 KB ans=YES N=8
16 Correct 0 ms 212 KB ans=NO N=2
17 Correct 0 ms 212 KB ans=YES N=17
18 Incorrect 1 ms 212 KB Added cell 25 (-1,1) not reachable from infinity
19 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 133 ms 15204 KB ans=NO N=66151
2 Correct 146 ms 33568 KB ans=NO N=64333
3 Incorrect 107 ms 11200 KB Contestant's solution is not lexicographically largest at index 69316 (69235 vs 27956)
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 1492 KB ans=NO N=1934
2 Correct 3 ms 724 KB ans=NO N=1965
3 Incorrect 3 ms 596 KB Contestant's solution is not lexicographically largest at index 1824 (1813 vs 585)
4 Halted 0 ms 0 KB -