Submission #524616

#TimeUsernameProblemLanguageResultExecution timeMemory
524616ammar2000Building Skyscrapers (CEOI19_skyscrapers)C++17
8 / 100
182 ms15808 KiB
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define F first
#define S second
#define coy cout<<"YES\n"
#define con cout<<"NO\n"
#define co1 cout<<"-1\n"
#define sc(x) scanf("%lld",&x)
#define all(x) x.begin(),x.end()
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
const int SI=3e5+7;
ll INF=8e18+7;
int dx[] = {1 , -1 , 0 , 0, 1 , 1,-1,-1};
int dy[] = {0 , 0 , 1 , -1, 1 , -1 , 1 ,-1};
int MOD=1e9+7;
ll n,t;
map < pair <ll,ll> ,ll> mp,vis;
pair  <ll,ll> p[SI];
vector < ll> ans;
queue < pair < ll,ll> > q;
void BFS()
{
    q.push(p[1]);
    while (q.size())
    {
        ll x=q.front().F,y=q.front().S;
        q.pop();
        pair < ll,ll> XY={x,y};
        vis[XY]=1;
        ans.pb(mp[XY]);
        for (int i=0;i<8;i++)
        {
            if(vis[{x+dx[i],y+dy[i]}]==0&&mp[{x+dx[i],y+dy[i]}]>0)
                q.push({x+dx[i],y+dy[i]}),vis[{x+dx[i],y+dy[i]}]=1;
        }
    }
}
int main()
{
   fast
   cin>>n>>t;
   for (int i=1;i<=n;i++)
   {
       ll a,b;
       cin>>a>>b;
       mp[{a,b}]=i;
       p[i]={a,b};
   }
   BFS();
   if (ans.size()!=n)
    con;
   else
   {
       coy;
       for (auto i:ans)
        cout << i<<"\n";
   }
   // use scanf not cin
   return 0;
}

Compilation message (stderr)

skyscrapers.cpp: In function 'int main()':
skyscrapers.cpp:52:18: 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]
   52 |    if (ans.size()!=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...