#include<bits/stdc++.h>
#define mod 1000000007
#define inf 100000000000000000
using namespace std;
unordered_map<int , unordered_map<int , int> >ist;
vector<vector<int> >num;
priority_queue<vector<int> >q;
vector<int>erg;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int menge , numm , nummer , que;
cin >> menge >> que;
for(int i = 0 ; i < menge ; i++){
cin >> numm >> nummer;
ist[numm][nummer] = i + 1;
num.push_back({numm , nummer , i + 1});
}
ist[num[num.size() - 1][0]][num[num.size() - 1][1]] = 0;
sort(num.begin() , num.end());
q.push(num[num.size() - 1]);
while(q.size()){
int x = q.top()[0] , y = q.top()[1] , z = q.top()[2];
// cout << z << "\n";
erg.push_back(z);
q.pop();
for(int i = -1 ; i <= 1 ; i++){
for(int j = -1 ; j <= 1 ; j++){
if(ist[x + i][y + j] > 0){
q.push({x + i , y + j , ist[x + i][y + j]});
ist[x + i][y + j] = 0;
}
}
}
}
if(erg.size() == menge){
cout << "YES\n";
for(int i = 0 ; i < erg.size() ; i++){
cout << erg[i] << "\n";
}
}
else{
cout << "NO\n";
}
}
Compilation message
skyscrapers.cpp: In function 'int main()':
skyscrapers.cpp:36:18: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
36 | if(erg.size() == menge){
| ~~~~~~~~~~~^~~~~~~~
skyscrapers.cpp:38:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
38 | for(int i = 0 ; i < erg.size() ; i++){
| ~~^~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
ans=YES N=1 |
2 |
Correct |
1 ms |
212 KB |
ans=YES N=4 |
3 |
Correct |
0 ms |
212 KB |
ans=NO N=4 |
4 |
Correct |
0 ms |
212 KB |
ans=YES N=5 |
5 |
Correct |
0 ms |
212 KB |
ans=YES N=9 |
6 |
Incorrect |
0 ms |
212 KB |
Each cell must be removed exactly once |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
ans=YES N=1 |
2 |
Correct |
1 ms |
212 KB |
ans=YES N=4 |
3 |
Correct |
0 ms |
212 KB |
ans=NO N=4 |
4 |
Correct |
0 ms |
212 KB |
ans=YES N=5 |
5 |
Correct |
0 ms |
212 KB |
ans=YES N=9 |
6 |
Incorrect |
0 ms |
212 KB |
Each cell must be removed exactly once |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
ans=YES N=1 |
2 |
Correct |
1 ms |
212 KB |
ans=YES N=4 |
3 |
Correct |
0 ms |
212 KB |
ans=NO N=4 |
4 |
Correct |
0 ms |
212 KB |
ans=YES N=5 |
5 |
Correct |
0 ms |
212 KB |
ans=YES N=9 |
6 |
Incorrect |
0 ms |
212 KB |
Each cell must be removed exactly once |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
852 KB |
ans=NO N=1934 |
2 |
Correct |
1 ms |
468 KB |
ans=NO N=1965 |
3 |
Incorrect |
2 ms |
468 KB |
Each cell must be removed exactly once |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
ans=YES N=1 |
2 |
Correct |
1 ms |
212 KB |
ans=YES N=4 |
3 |
Correct |
0 ms |
212 KB |
ans=NO N=4 |
4 |
Correct |
0 ms |
212 KB |
ans=YES N=5 |
5 |
Correct |
0 ms |
212 KB |
ans=YES N=9 |
6 |
Incorrect |
0 ms |
212 KB |
Each cell must be removed exactly once |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
95 ms |
9208 KB |
ans=NO N=66151 |
2 |
Correct |
43 ms |
6760 KB |
ans=NO N=64333 |
3 |
Incorrect |
125 ms |
8376 KB |
Each cell must be removed exactly once |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
852 KB |
ans=NO N=1934 |
2 |
Correct |
1 ms |
468 KB |
ans=NO N=1965 |
3 |
Incorrect |
2 ms |
468 KB |
Each cell must be removed exactly once |
4 |
Halted |
0 ms |
0 KB |
- |