Submission #564532

# Submission time Handle Problem Language Result Execution time Memory
564532 2022-05-19T10:35:45 Z Uzouf Building Skyscrapers (CEOI19_skyscrapers) C++14
8 / 100
250 ms 20436 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define endl "\n"
int mod=1e9+7;
const int N=2e5+5;
template<class x>
using ordered_multiset = tree<x, null_type,less_equal<x>, rb_tree_tag,tree_order_statistics_node_update>;

int n,t;
map<pair<int,int>,bool> mp;
map<pair<int,int>,bool> vis;
map<pair<int,int>,int> plc;
vector<pair<int,int> > v;
vector<pair<int,int> > vv;

int dx[8]={0,0,1,-1,1,-1,-1,1};
int dy[8]={1,-1,0,0,1,-1,1,-1};

signed main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen(".in", "r", stdin); freopen(".out", "w", stdout);

    cin>>n>>t;
    for (int i=0;i<n;i++) {
      int x,y; cin>>x>>y;
      mp[{x,y}]=true;
      plc[{x,y}]=i+1;
      v.push_back({x,y});
      vv.push_back({y,x});
    }
    sort(v.begin(),v.end());

    queue<pair<int,int> > q;

    int fx=v[0].first,fy=v[0].second;
    int lx=v[n-1].first,ly=v[n-1].second;
    for (auto i:v) {
      if (q.size()>0) {break;}
      if (i.first==fx && !vis[i]) {
        q.push({i}); vis[i]=true;
      }
      if (i.second==fy && !vis[i]) {
        q.push({i}); vis[i]=true;
      }
      if (i.first==lx && !vis[i]) {
        q.push({i}); vis[i]=true;
      }
      if (i.second==ly && !vis[i]) {
        q.push({i}); vis[i]=true;
      }
    }

    vector<int> ans;

    while (!q.empty()) {
      int x=q.front().first,y=q.front().second;
      q.pop();
      ans.push_back(plc[{x,y}]);

      for (int i=0;i<8;i++) {
        int xx=x+dx[i],yy=y+dy[i];
        if (!vis[{xx,yy}] && mp[{xx,yy}]) {
          q.push({xx,yy}); vis[{xx,yy}]=true;
        }

      }
    }

    for (auto i:v) {
      if (!vis[i]) {
        cout<<"NO"; return 0;
      }
    }

    cout<<"YES"<<endl;
    for (int i:ans) cout<<i<<endl;

}
# Verdict Execution time Memory Grader output
1 Correct 0 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 Correct 1 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 0 ms 212 KB ans=YES N=8
15 Correct 0 ms 212 KB ans=YES N=8
16 Correct 0 ms 212 KB ans=NO N=2
# Verdict Execution time Memory Grader output
1 Correct 0 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 Correct 1 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 0 ms 212 KB ans=YES N=8
15 Correct 0 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 0 ms 212 KB Added cell 25 (1,-1) not reachable from infinity
19 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 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 Correct 1 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 0 ms 212 KB ans=YES N=8
15 Correct 0 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 0 ms 212 KB Added cell 25 (1,-1) not reachable from infinity
19 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 596 KB ans=NO N=1934
2 Correct 3 ms 596 KB ans=NO N=1965
3 Incorrect 3 ms 724 KB Contestant's solution is not lexicographically largest at index 1824 (1813 vs 1702)
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 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 Correct 1 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 0 ms 212 KB ans=YES N=8
15 Correct 0 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 0 ms 212 KB Added cell 25 (1,-1) not reachable from infinity
19 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 250 ms 20436 KB ans=NO N=66151
2 Correct 63 ms 10320 KB ans=NO N=64333
3 Incorrect 164 ms 16964 KB Contestant's solution is not lexicographically largest at index 69316 (69235 vs 13970)
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 596 KB ans=NO N=1934
2 Correct 3 ms 596 KB ans=NO N=1965
3 Incorrect 3 ms 724 KB Contestant's solution is not lexicographically largest at index 1824 (1813 vs 1702)
4 Halted 0 ms 0 KB -