Submission #392091

# Submission time Handle Problem Language Result Execution time Memory
392091 2021-04-20T13:28:28 Z elabensaad Building Skyscrapers (CEOI19_skyscrapers) C++14
0 / 100
45 ms 4472 KB
#include <bits/stdc++.h>
 
using namespace std;
 
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

int t[3100][3200], vis[5000][3300], mj, mi;
vector <int> ans;
int di[10] = {0, 0, 1, 1, 1, -1, -1, -1};
int dj[10] = {1, -1, 0, -1, 1, 0, -1, 1};

void dfs(int u, int v){
	vis[u][v] = 1;
	ans.push_back(t[u][v]);
	for(int i = 0;i < 8;i++){
		int ci = u+di[i];
		int cj = v+dj[i];
		if(ci <= mi && cj <= mj && ci >= 0 && cj >= 0){
			if(t[ci][cj] != 0 && vis[ci][cj] == 0){
				dfs(ci, cj);
			}
		}
	}
}

int main() {
	//freopen("haircut.in", "r", stdin);
	//freopen("haircut.out", "w", stdout);
	int n, q, x, y;
	cin >> n >> q;
	for(int i = 0;i < n;i++){
		cin >> x >> y;
		t[x][y] = i+1;
		mi = max(mi, x);
		mj = max(mj, y);
	}
	//cout << x << ' ' << y << endl;
	dfs(x, y);
	/*for(int i = 0;i < ans.size();i++){
		cout << ans[i] << ' ';
	}*/
	if(ans.size() != n)cout << "NO" << endl;
	else {
		cout << "YES" << endl;
		for(int i = ans.size()-1;i >= 0;i--){
			cout << ans[i] << endl;
		}
	}
}
//cout << "Case " << c << ": "  << 
/*
7 12
??00?101??1?0?100??
9
4 4
01?????0
3 3
??????
1 0
?
2 2
0101
2 2
01?0
0 1
0
0 3
1?1
2 2
?00?
4 3
??010?0

*/

Compilation message

skyscrapers.cpp:6: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
    6 | #pragma GCC optimization ("O3")
      | 
skyscrapers.cpp:7: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
    7 | #pragma GCC optimization ("unroll-loops")
      | 
skyscrapers.cpp: In function 'int main()':
skyscrapers.cpp:44:16: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   44 |  if(ans.size() != n)cout << "NO" << endl;
      |     ~~~~~~~~~~~^~~~
# Verdict Execution time Memory Grader output
1 Runtime error 7 ms 332 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 7 ms 332 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 7 ms 332 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 6 ms 332 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 7 ms 332 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 45 ms 4472 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 6 ms 332 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -