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>
using namespace std;
#define int ll
#define ll long long
const int inf = 1e9 + 7;
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
const int sz = 2e5 + 5;
bool isadj(pair<int,int>& a, pair<int,int>& b){
int x1 = a.first;
int x2 = b.first;
int y1 = a.second;
int y2 = b.second;
if(x1 == x2){
return abs(y1 - y2) < 2;
}
if(y1 == y2){
return abs(x1 - x2) < 2;
}
int sum = abs(x1 - x2) + abs(y1 - y2);
return sum <= 2;
}
signed main(){
int n, t;
cin >> n >> t;
vector<pair<int,int>> a(n);
vector<pair<pair<int,int>, int>>v;
for(int i = 0; i < n; ++i){
cin >> a[i].first >> a[i].second;
v.push_back({{a[i].first, a[i].second}, i + 1});
}
sort(begin(v), end(v));
bool ok = false;
for(int i = 1; i < n; ++i){
if(!isadj(v[i].first, v[i - 1].first)){
ok = true;
}
}
if(ok){
cout << "NO" << endl;
}else{
cout << "YES" << endl;
for(int i = 0; i < n; ++i){
cout << v[i].second << endl;
}
}
}
# | 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... |