답안 #895078

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
895078 2023-12-29T11:40:24 Z Muhammad_Aneeq 분수 공원 (IOI21_parks) C++17
5 / 100
690 ms 44496 KB
#include <vector>
#include <map>
#include <queue>
#include "parks.h"
using namespace std;
map<pair<int,int>,int>d,vis;
vector<pair<int,int>>z;
queue<pair<int,int>>Q;
int x1=0,y11=0;
void check(int x,int y)
{
	if (d.find({x,y})!=d.end()&&!vis[{x,y}])
	{
		Q.push({x,y});
		vis[{x,y}]=1;
		z.push_back({d[{x1,y11}],d[{x,y}]});
	}
}
void bfs(int x,int y)
{
	Q.push({x,y});
	vis[{x,y}]=1;
	while (Q.size())
	{
		x,y;
		tie(x,y)=Q.front();
		x1=x,y11=y;
		Q.pop();
		check(x,y-2);
		check(x,y+2);
		check(x-2,y);
		check(x+2,y);
	}
}
int construct_roads(vector<int> x, vector<int> y)
{
	int n=x.size();
	for (int i=0;i<n;i++)
		d[{x[i],y[i]}]=i;
	int reqx=1e9+10,reqy=1e9+10;
	for (int i=0;i<n;i++)
	{
		if (x[i]<reqx)
		{
			reqx=x[i];
			reqy=y[i];
		}
		else if (x[i]==reqx&&reqy>y[i])
			reqy=y[i];
	}
	bfs(reqx,reqy);
	for (int i=0;i<n;i++)
	{
		if (!vis[{x[i],y[i]}])
			return 0;
	}
	vis={};
	vector<int>u,v,a,b;
	for (auto i:z)
	{
		u.push_back(i.first);
		v.push_back(i.second);
		pair<int,int>r,q;
		r.first=x[i.first],r.second=y[i.first];
		q.first=x[i.second],q.second=y[i.second];
		if (r.first-q.first==0)
		{
			a.push_back(r.first-1);
			b.push_back((r.second+q.second)/2);
			if (vis[{a.back(),b.back()}])
			{
				a.pop_back();
				a.push_back(r.first+1);
				if (vis[{a.back(),b.back()}])
					return 0;
				vis[{a.back(),b.back()}]=1;
			}
			else
				vis[{a.back(),b.back()}]=1;
		}
		else
		{
			a.push_back((r.first+q.first)/2);
			b.push_back(r.second-1);
			if (vis[{a.back(),b.back()}])
			{
				b.pop_back();
				b.push_back(r.second+1);
				if (vis[{a.back(),b.back()}])
					return 0;
				vis[{a.back(),b.back()}]=1;
			}
			else
				vis[{a.back(),b.back()}]=1;
		}
	}
	build(u,v,a,b);
	return 1;
}

Compilation message

parks.cpp: In function 'void bfs(int, int)':
parks.cpp:25:3: warning: left operand of comma operator has no effect [-Wunused-value]
   25 |   x,y;
      |   ^
parks.cpp:25:6: warning: right operand of comma operator has no effect [-Wunused-value]
   25 |   x,y;
      |      ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 356 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 177 ms 21592 KB Output is correct
10 Correct 16 ms 2392 KB Output is correct
11 Correct 90 ms 11652 KB Output is correct
12 Correct 20 ms 3416 KB Output is correct
13 Correct 42 ms 5956 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 604 KB Output is correct
16 Correct 186 ms 21532 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 356 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 177 ms 21592 KB Output is correct
10 Correct 16 ms 2392 KB Output is correct
11 Correct 90 ms 11652 KB Output is correct
12 Correct 20 ms 3416 KB Output is correct
13 Correct 42 ms 5956 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 604 KB Output is correct
16 Correct 186 ms 21532 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 518 ms 42924 KB Output is correct
24 Correct 0 ms 344 KB Output is correct
25 Correct 2 ms 604 KB Output is correct
26 Correct 2 ms 604 KB Output is correct
27 Correct 2 ms 856 KB Output is correct
28 Correct 166 ms 18096 KB Output is correct
29 Correct 264 ms 26648 KB Output is correct
30 Correct 373 ms 35496 KB Output is correct
31 Correct 504 ms 44496 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 0 ms 348 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 0 ms 348 KB Output is correct
37 Correct 0 ms 348 KB Output is correct
38 Correct 0 ms 344 KB Output is correct
39 Correct 0 ms 348 KB Output is correct
40 Correct 0 ms 344 KB Output is correct
41 Correct 0 ms 348 KB Output is correct
42 Correct 0 ms 348 KB Output is correct
43 Correct 2 ms 604 KB Output is correct
44 Correct 1 ms 604 KB Output is correct
45 Incorrect 133 ms 16068 KB Solution announced impossible, but it is possible.
46 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 356 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 177 ms 21592 KB Output is correct
10 Correct 16 ms 2392 KB Output is correct
11 Correct 90 ms 11652 KB Output is correct
12 Correct 20 ms 3416 KB Output is correct
13 Correct 42 ms 5956 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 604 KB Output is correct
16 Correct 186 ms 21532 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 518 ms 42924 KB Output is correct
24 Correct 0 ms 344 KB Output is correct
25 Correct 2 ms 604 KB Output is correct
26 Correct 2 ms 604 KB Output is correct
27 Correct 2 ms 856 KB Output is correct
28 Correct 166 ms 18096 KB Output is correct
29 Correct 264 ms 26648 KB Output is correct
30 Correct 373 ms 35496 KB Output is correct
31 Correct 504 ms 44496 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 0 ms 348 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 0 ms 348 KB Output is correct
37 Correct 0 ms 348 KB Output is correct
38 Correct 0 ms 344 KB Output is correct
39 Correct 0 ms 348 KB Output is correct
40 Correct 0 ms 344 KB Output is correct
41 Correct 0 ms 348 KB Output is correct
42 Correct 0 ms 348 KB Output is correct
43 Correct 2 ms 604 KB Output is correct
44 Correct 1 ms 604 KB Output is correct
45 Incorrect 133 ms 16068 KB Solution announced impossible, but it is possible.
46 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 356 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 177 ms 21592 KB Output is correct
10 Correct 16 ms 2392 KB Output is correct
11 Correct 90 ms 11652 KB Output is correct
12 Correct 20 ms 3416 KB Output is correct
13 Correct 42 ms 5956 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 604 KB Output is correct
16 Correct 186 ms 21532 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 500 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 503 ms 43772 KB Output is correct
21 Correct 540 ms 43500 KB Output is correct
22 Correct 453 ms 43644 KB Output is correct
23 Correct 395 ms 36544 KB Output is correct
24 Correct 116 ms 15820 KB Output is correct
25 Correct 109 ms 15880 KB Output is correct
26 Correct 110 ms 16076 KB Output is correct
27 Correct 690 ms 42928 KB Output is correct
28 Correct 591 ms 42892 KB Output is correct
29 Correct 607 ms 42776 KB Output is correct
30 Incorrect 543 ms 30148 KB Solution announced impossible, but it is possible.
31 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 356 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 177 ms 21592 KB Output is correct
10 Correct 16 ms 2392 KB Output is correct
11 Correct 90 ms 11652 KB Output is correct
12 Correct 20 ms 3416 KB Output is correct
13 Correct 42 ms 5956 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 604 KB Output is correct
16 Correct 186 ms 21532 KB Output is correct
17 Correct 502 ms 43176 KB Output is correct
18 Correct 497 ms 43624 KB Output is correct
19 Correct 455 ms 43632 KB Output is correct
20 Correct 626 ms 41624 KB Output is correct
21 Correct 592 ms 37384 KB Output is correct
22 Correct 1 ms 344 KB Output is correct
23 Incorrect 53 ms 5028 KB Solution announced impossible, but it is possible.
24 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 356 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 177 ms 21592 KB Output is correct
10 Correct 16 ms 2392 KB Output is correct
11 Correct 90 ms 11652 KB Output is correct
12 Correct 20 ms 3416 KB Output is correct
13 Correct 42 ms 5956 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 604 KB Output is correct
16 Correct 186 ms 21532 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 518 ms 42924 KB Output is correct
24 Correct 0 ms 344 KB Output is correct
25 Correct 2 ms 604 KB Output is correct
26 Correct 2 ms 604 KB Output is correct
27 Correct 2 ms 856 KB Output is correct
28 Correct 166 ms 18096 KB Output is correct
29 Correct 264 ms 26648 KB Output is correct
30 Correct 373 ms 35496 KB Output is correct
31 Correct 504 ms 44496 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 0 ms 348 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 0 ms 348 KB Output is correct
37 Correct 0 ms 348 KB Output is correct
38 Correct 0 ms 344 KB Output is correct
39 Correct 0 ms 348 KB Output is correct
40 Correct 0 ms 344 KB Output is correct
41 Correct 0 ms 348 KB Output is correct
42 Correct 0 ms 348 KB Output is correct
43 Correct 2 ms 604 KB Output is correct
44 Correct 1 ms 604 KB Output is correct
45 Incorrect 133 ms 16068 KB Solution announced impossible, but it is possible.
46 Halted 0 ms 0 KB -