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;
vector<int>moves = {-1, 0, 1};
signed main(){
int n, t;
cin >> n >> t;
vector<pair<int,int>> a(n);
vector<pair<pair<int,int>, int>>v;
map<pair<int,int>, int> ind, mp;
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});
mp[{a[i].first, a[i].second}] = 1;
ind[{a[i].first, a[i].second}] = i + 1;
}
int x = begin(mp) -> first.first;
int y = begin(mp) -> first.second;
set<pair<int,int>> st;
st.insert({x, y});
mp[{x, y}] = 2;
vector<int>res;
while(!st.empty()){
int x = begin(st)->first;
int y = begin(st)->second;
st.erase(begin(st));
res.push_back(ind[{x, y}]);
for(auto v1 : moves){
for(auto v2 : moves){
if(mp[{x + v1, y + v2}] == 1){
mp[{x + v1, y + v2}] = 2;
st.insert({x + v1, y + v2});
}
}
}
}
bool ok = true;
for(int i = 0; i < n; ++i){
if(mp[{a[i].first, a[i].second}] == 1){
ok = false;
}
}
if(!ok){
cout << "NO" << endl;
return 0;
}
cout << "YES" << endl;
for(auto &i : res){
cout << i << 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... |