#include <queue>
#include <bitset>
#include <iostream>
#include <vector>
#include <algorithm>
#include <tuple>
using namespace std;
typedef long long ll;
vector<bitset<2*1000000001>> grid;
void setBits(int x,int y)
{
for(int i = x-1; i<= x+1; ++i)
{
for(int j = y-1; j<= y+1; ++j)
{
grid[x].set(y);
}
}
}
bool isAdjacent(pair<long, pair<long, int>>s1, pair<long, pair<long, int>>s2)
{ return abs(s1.first -s2.first ) <= 1 && abs(s1.second.first - s2.second.first) <=1;}
bitset<150000> visited;
vector<vector<int>> adjList;
vector<pair<long,pair<long, int>>> buildings;
vector<int> order;
void BFS(int startNode)
{
queue<int> nodeList;
nodeList.push(startNode);
visited.set(startNode);
while(nodeList.size() != 0)
{
int newNode = nodeList.front();
nodeList.pop();
order.push_back(newNode);
for(auto node:adjList[newNode])
{
if(!visited.test(node))
{
nodeList.push(node);
visited.set(node);
}
}
}
}
int main()
{
int n; cin>>n;
int t; cin>>t;
buildings.resize(n);
for(int i = 0; i<n; ++i)
{
long a; long b; cin>>a>>b;
buildings[i] = {a,{b, i}};
}
adjList.resize(n);
sort(buildings.begin(), buildings.end());
for(int i = 0; i<n-1; ++i)
{
for(int j = i+1; j<n; ++j)
{
if(buildings[j].first - buildings[i].first > 1)
break;
else
{
if(isAdjacent(buildings[i], buildings[j]))
{
adjList[i].push_back(j);
adjList[j].push_back(i);
}
}
}
}
//DFS
BFS(0);
for(int i = 0; i<n; ++i)
{
if(!visited.test(i))
{
cout<<"NO"<<endl;
return 0;
}
}
cout<<"YES"<<endl;
for(int i = 0; i<n; ++i)
{
cout<<buildings[order[i]].second.second+1<<endl;
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 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 |
Correct |
0 ms |
212 KB |
ans=YES N=5 |
7 |
Correct |
1 ms |
212 KB |
ans=NO N=9 |
8 |
Correct |
0 ms |
212 KB |
ans=NO N=10 |
9 |
Correct |
1 ms |
212 KB |
ans=YES N=10 |
10 |
Correct |
0 ms |
212 KB |
ans=YES N=10 |
11 |
Correct |
0 ms |
212 KB |
ans=YES N=10 |
12 |
Correct |
0 ms |
212 KB |
ans=YES N=9 |
13 |
Correct |
0 ms |
212 KB |
ans=YES N=9 |
14 |
Correct |
1 ms |
212 KB |
ans=YES N=8 |
15 |
Correct |
1 ms |
212 KB |
ans=YES N=8 |
16 |
Correct |
1 ms |
212 KB |
ans=NO N=2 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 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 |
Correct |
0 ms |
212 KB |
ans=YES N=5 |
7 |
Correct |
1 ms |
212 KB |
ans=NO N=9 |
8 |
Correct |
0 ms |
212 KB |
ans=NO N=10 |
9 |
Correct |
1 ms |
212 KB |
ans=YES N=10 |
10 |
Correct |
0 ms |
212 KB |
ans=YES N=10 |
11 |
Correct |
0 ms |
212 KB |
ans=YES N=10 |
12 |
Correct |
0 ms |
212 KB |
ans=YES N=9 |
13 |
Correct |
0 ms |
212 KB |
ans=YES N=9 |
14 |
Correct |
1 ms |
212 KB |
ans=YES N=8 |
15 |
Correct |
1 ms |
212 KB |
ans=YES N=8 |
16 |
Correct |
1 ms |
212 KB |
ans=NO N=2 |
17 |
Correct |
0 ms |
212 KB |
ans=YES N=17 |
18 |
Correct |
1 ms |
308 KB |
ans=YES N=25 |
19 |
Correct |
1 ms |
212 KB |
ans=YES N=100 |
20 |
Correct |
1 ms |
212 KB |
ans=YES N=185 |
21 |
Correct |
1 ms |
212 KB |
ans=NO N=174 |
22 |
Correct |
1 ms |
212 KB |
ans=YES N=90 |
23 |
Correct |
1 ms |
212 KB |
ans=YES N=63 |
24 |
Correct |
1 ms |
212 KB |
ans=YES N=87 |
25 |
Correct |
1 ms |
316 KB |
ans=YES N=183 |
26 |
Correct |
1 ms |
212 KB |
ans=YES N=188 |
27 |
Correct |
1 ms |
212 KB |
ans=YES N=183 |
28 |
Correct |
1 ms |
316 KB |
ans=YES N=189 |
29 |
Correct |
1 ms |
212 KB |
ans=YES N=200 |
30 |
Correct |
1 ms |
212 KB |
ans=YES N=190 |
31 |
Correct |
1 ms |
340 KB |
ans=YES N=187 |
32 |
Correct |
1 ms |
212 KB |
ans=YES N=187 |
33 |
Correct |
1 ms |
212 KB |
ans=YES N=182 |
34 |
Correct |
1 ms |
212 KB |
ans=YES N=184 |
35 |
Correct |
1 ms |
212 KB |
ans=YES N=188 |
36 |
Correct |
1 ms |
212 KB |
ans=YES N=181 |
37 |
Correct |
1 ms |
212 KB |
ans=YES N=188 |
38 |
Correct |
1 ms |
212 KB |
ans=YES N=191 |
39 |
Incorrect |
1 ms |
212 KB |
Added cell 196 (16,2) not reachable from infinity |
40 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 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 |
Correct |
0 ms |
212 KB |
ans=YES N=5 |
7 |
Correct |
1 ms |
212 KB |
ans=NO N=9 |
8 |
Correct |
0 ms |
212 KB |
ans=NO N=10 |
9 |
Correct |
1 ms |
212 KB |
ans=YES N=10 |
10 |
Correct |
0 ms |
212 KB |
ans=YES N=10 |
11 |
Correct |
0 ms |
212 KB |
ans=YES N=10 |
12 |
Correct |
0 ms |
212 KB |
ans=YES N=9 |
13 |
Correct |
0 ms |
212 KB |
ans=YES N=9 |
14 |
Correct |
1 ms |
212 KB |
ans=YES N=8 |
15 |
Correct |
1 ms |
212 KB |
ans=YES N=8 |
16 |
Correct |
1 ms |
212 KB |
ans=NO N=2 |
17 |
Correct |
0 ms |
212 KB |
ans=YES N=17 |
18 |
Correct |
1 ms |
308 KB |
ans=YES N=25 |
19 |
Correct |
1 ms |
212 KB |
ans=YES N=100 |
20 |
Correct |
1 ms |
212 KB |
ans=YES N=185 |
21 |
Correct |
1 ms |
212 KB |
ans=NO N=174 |
22 |
Correct |
1 ms |
212 KB |
ans=YES N=90 |
23 |
Correct |
1 ms |
212 KB |
ans=YES N=63 |
24 |
Correct |
1 ms |
212 KB |
ans=YES N=87 |
25 |
Correct |
1 ms |
316 KB |
ans=YES N=183 |
26 |
Correct |
1 ms |
212 KB |
ans=YES N=188 |
27 |
Correct |
1 ms |
212 KB |
ans=YES N=183 |
28 |
Correct |
1 ms |
316 KB |
ans=YES N=189 |
29 |
Correct |
1 ms |
212 KB |
ans=YES N=200 |
30 |
Correct |
1 ms |
212 KB |
ans=YES N=190 |
31 |
Correct |
1 ms |
340 KB |
ans=YES N=187 |
32 |
Correct |
1 ms |
212 KB |
ans=YES N=187 |
33 |
Correct |
1 ms |
212 KB |
ans=YES N=182 |
34 |
Correct |
1 ms |
212 KB |
ans=YES N=184 |
35 |
Correct |
1 ms |
212 KB |
ans=YES N=188 |
36 |
Correct |
1 ms |
212 KB |
ans=YES N=181 |
37 |
Correct |
1 ms |
212 KB |
ans=YES N=188 |
38 |
Correct |
1 ms |
212 KB |
ans=YES N=191 |
39 |
Incorrect |
1 ms |
212 KB |
Added cell 196 (16,2) not reachable from infinity |
40 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
340 KB |
ans=NO N=1934 |
2 |
Correct |
2 ms |
468 KB |
ans=NO N=1965 |
3 |
Incorrect |
5 ms |
468 KB |
Contestant's solution is not lexicographically largest at index 1824 (1813 vs 1702) |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 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 |
Correct |
0 ms |
212 KB |
ans=YES N=5 |
7 |
Correct |
1 ms |
212 KB |
ans=NO N=9 |
8 |
Correct |
0 ms |
212 KB |
ans=NO N=10 |
9 |
Correct |
1 ms |
212 KB |
ans=YES N=10 |
10 |
Correct |
0 ms |
212 KB |
ans=YES N=10 |
11 |
Correct |
0 ms |
212 KB |
ans=YES N=10 |
12 |
Correct |
0 ms |
212 KB |
ans=YES N=9 |
13 |
Correct |
0 ms |
212 KB |
ans=YES N=9 |
14 |
Correct |
1 ms |
212 KB |
ans=YES N=8 |
15 |
Correct |
1 ms |
212 KB |
ans=YES N=8 |
16 |
Correct |
1 ms |
212 KB |
ans=NO N=2 |
17 |
Correct |
0 ms |
212 KB |
ans=YES N=17 |
18 |
Correct |
1 ms |
308 KB |
ans=YES N=25 |
19 |
Correct |
1 ms |
212 KB |
ans=YES N=100 |
20 |
Correct |
1 ms |
212 KB |
ans=YES N=185 |
21 |
Correct |
1 ms |
212 KB |
ans=NO N=174 |
22 |
Correct |
1 ms |
212 KB |
ans=YES N=90 |
23 |
Correct |
1 ms |
212 KB |
ans=YES N=63 |
24 |
Correct |
1 ms |
212 KB |
ans=YES N=87 |
25 |
Correct |
1 ms |
316 KB |
ans=YES N=183 |
26 |
Correct |
1 ms |
212 KB |
ans=YES N=188 |
27 |
Correct |
1 ms |
212 KB |
ans=YES N=183 |
28 |
Correct |
1 ms |
316 KB |
ans=YES N=189 |
29 |
Correct |
1 ms |
212 KB |
ans=YES N=200 |
30 |
Correct |
1 ms |
212 KB |
ans=YES N=190 |
31 |
Correct |
1 ms |
340 KB |
ans=YES N=187 |
32 |
Correct |
1 ms |
212 KB |
ans=YES N=187 |
33 |
Correct |
1 ms |
212 KB |
ans=YES N=182 |
34 |
Correct |
1 ms |
212 KB |
ans=YES N=184 |
35 |
Correct |
1 ms |
212 KB |
ans=YES N=188 |
36 |
Correct |
1 ms |
212 KB |
ans=YES N=181 |
37 |
Correct |
1 ms |
212 KB |
ans=YES N=188 |
38 |
Correct |
1 ms |
212 KB |
ans=YES N=191 |
39 |
Incorrect |
1 ms |
212 KB |
Added cell 196 (16,2) not reachable from infinity |
40 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
117 ms |
6716 KB |
ans=NO N=66151 |
2 |
Correct |
76 ms |
4132 KB |
ans=NO N=64333 |
3 |
Incorrect |
256 ms |
7624 KB |
Contestant's solution is not lexicographically largest at index 69316 (69235 vs 7320) |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
340 KB |
ans=NO N=1934 |
2 |
Correct |
2 ms |
468 KB |
ans=NO N=1965 |
3 |
Incorrect |
5 ms |
468 KB |
Contestant's solution is not lexicographically largest at index 1824 (1813 vs 1702) |
4 |
Halted |
0 ms |
0 KB |
- |