Submission #210853

#TimeUsernameProblemLanguageResultExecution timeMemory
210853LawlietBuilding Skyscrapers (CEOI19_skyscrapers)C++17
54 / 100
757 ms51560 KiB
#include <bits/stdc++.h> using namespace std; typedef pair<int,int> pii; const int MAXN = 150010; int dx[] = { 0 , 0 , 1 , -1 , 1 , -1 , 1 , -1 }; int dy[] = { 1 , -1 , 0 , 0 , 1 , 1 , -1 , -1 }; int n, t; pii v[MAXN]; vector< int > ans; map< pii , int > ind; map< pii , bool > marc; void topologicalSorting(int iniX, int iniY) { set< pii > s; s.insert( { iniX , iniY } ); marc[ { iniX , iniY } ] = true; while( !s.empty() ) { int curX = s.begin()->first; int curY = s.begin()->second; s.erase( s.begin() ); ans.push_back( ind[ { curX , curY } ] ); for(int d = 0 ; d < 8 ; d++) { int nextX = curX + dx[d]; int nextY = curY + dy[d]; if( ind[ { nextX , nextY } ] == 0 ) continue; if( marc[ { nextX , nextY } ] ) continue; s.insert( { nextX , nextY } ); marc[ { nextX , nextY } ] = true; } } } int main() { scanf("%d %d",&n,&t); for(int i = 1 ; i <= n ; i++) { int x, y; scanf("%d %d",&x,&y); v[i] = { x , y }; ind[ v[i] ] = i; } int ini = 1; for(int i = 2 ; i <= n ; i++) if( v[i].first < v[ini].first ) ini = i; topologicalSorting( v[ini].first , v[ini].second ); if( ans.size() != n ) { printf("NO\n"); return 0; } printf("YES\n"); for(int i = 0 ; i < ans.size() ; i++) printf("%d\n",ans[i]); }

Compilation message (stderr)

skyscrapers.cpp: In function 'int main()':
skyscrapers.cpp:69:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  if( ans.size() != n )
      ~~~~~~~~~~~^~~~
skyscrapers.cpp:77:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i = 0 ; i < ans.size() ; i++)
                  ~~^~~~~~~~~~~~
skyscrapers.cpp:51:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d",&n,&t);
  ~~~~~^~~~~~~~~~~~~~~
skyscrapers.cpp:56:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d",&x,&y);
   ~~~~~^~~~~~~~~~~~~~~
#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...