This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
#define mod 1000000007
#define inf 100000000000000000
using namespace std;
unordered_map<long long , unordered_map<long long , long long> >ist;
vector<vector<long long> >num;
priority_queue<vector<long long> >q;
vector<long long>erg;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
long long menge , numm , nummer , que;
cin >> menge >> que;
for(long long i = 0 ; i < menge ; i++){
cin >> numm >> nummer;
ist[numm][nummer] = i + 1;
num.push_back({numm , nummer , i + 1});
}
ist[num[0][0]][num[0][1]] = 0;
sort(num.begin() , num.end());
q.push(num[0]);
while(q.size()){
long long x = q.top()[0] , y = q.top()[1] , z = q.top()[2];
// cout << z << "\n";
erg.push_back(z);
q.pop();
for(long long i = -1 ; i <= 1 ; i++){
for(long long 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(long long i = 0 ; i < erg.size() ; i++){
cout << erg[i] << "\n";
}
}
else{
cout << "NO\n";
}
}
Compilation message (stderr)
skyscrapers.cpp: In function 'int main()':
skyscrapers.cpp:36: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]
36 | if(erg.size() == menge){
| ~~~~~~~~~~~^~~~~~~~
skyscrapers.cpp:38:31: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
38 | for(long long i = 0 ; i < erg.size() ; i++){
| ~~^~~~~~~~~~~~
# | 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... |