Submission #944006

#TimeUsernameProblemLanguageResultExecution timeMemory
944006vjudge1Building Skyscrapers (CEOI19_skyscrapers)C++17
54 / 100
514 ms52040 KiB
#include <bits/stdc++.h> #define int long long #define ff first #define ss second #define pb push_back #define all(x) x.begin(),x.end() using namespace std; signed main(){ ios_base::sync_with_stdio(); cin.tie(0);cout.tie(0); int n,t; cin>>n>>t; vector <int> x(n),y(n); map <pair <int,int> ,int> mp,ind; for(int i=0;i<n;i++){ cin>>x[i]>>y[i]; mp[{x[i],y[i]}]=1; ind[{x[i],y[i]}]=i+1; } int X=mp.begin()->ff.ff; int Y=mp.begin()->ff.ss; set <pair <int,int> > st; vector <int> v={-1,0,1}; st.insert({X,Y}); mp[{X,Y}]=2; vector <int> ans; while(!st.empty()){ int X=st.begin()->ff; int Y=st.begin()->ss; st.erase(st.begin()); ans.pb(ind[{X,Y}]); for(auto a : v){ for(auto b : v){ if(mp[{X+a,Y+b}]==1){ mp[{X+a,Y+b}]=2; st.insert({X+a,Y+b}); } } } } bool ok=1; for(int i=0;i<n;i++){ if(mp[{x[i],y[i]}]==1){ ok=0;break; } } if(ok){ cout<<"YES\n"; for(auto x : ans)cout<<x<<" "; cout<<"\n"; } else cout<<"NO\n"; } /* */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...