이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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]);
}
컴파일 시 표준 에러 (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 time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... |