답안 #454771

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
454771 2021-08-05T08:06:21 Z ogibogi2004 분수 공원 (IOI21_parks) C++17
45 / 100
802 ms 60048 KB
#include "parks.h"
#include <bits/stdc++.h>
using namespace std;
const int MAXN=2e5+6;
vector<int>g[MAXN];
map<pair<int,int>,int> tochki;
bool vis[MAXN];
vector<pair<int,int> >roads;
int cnt;
void dfs(int u)
{
	vis[u]=1;
	cnt++;
	for(auto xd:g[u])
	{
		if(vis[xd])continue;
		dfs(xd);
		roads.push_back({u,xd});
	}
}
int construct_roads(vector<int> x, vector<int> y) {
    if (x.size() == 1) {
	build({}, {}, {}, {});
        return 1;
    }
    for(int i=0;i<x.size();i++)
    {
		tochki[make_pair(x[i],y[i])]=i;
	}
	for(int i=0;i<x.size();i++)
	{
		if(tochki.count(make_pair(x[i],y[i]-2)))
		{
			g[i].push_back(tochki[make_pair(x[i],y[i]-2)]);
		}
		if(tochki.count(make_pair(x[i],y[i]+2)))
		{
			g[i].push_back(tochki[make_pair(x[i],y[i]+2)]);
		}
		if(tochki.count(make_pair(x[i]+2,y[i])))
		{
			g[i].push_back(tochki[make_pair(x[i]+2,y[i])]);
		}
		if(tochki.count(make_pair(x[i]-2,y[i])))
		{
			g[i].push_back(tochki[make_pair(x[i]-2,y[i])]);
		}
	}
	dfs(0);
	if(cnt!=x.size())return 0;
	vector<int>u;
	vector<int>v;
	vector<int>a;
	vector<int>b;
	for(int i=0;i<roads.size();i++)
	{
		u.push_back(roads[i].first);
		v.push_back(roads[i].second);
		if(x[roads[i].first]==x[roads[i].second])
		{
			int x1=x[roads[i].first];
			int y1=min(y[roads[i].first],y[roads[i].second]);
			if((x1+y1)%4==0)
			{
				a.push_back(x1+1);
				b.push_back(y1+1);
			}
			else
			{
				a.push_back(x1-1);
				b.push_back(y1+1);
			}
		}
		else
		{
			int y1=y[roads[i].first];
			int x1=min(x[roads[i].first],x[roads[i].second]);
			if((x1+y1)%4==0)
			{
				a.push_back(x1+1);
				b.push_back(y1-1);
			}
			else
			{
				a.push_back(x1+1);
				b.push_back(y1+1);
			}
		}
	}
	build(u,v,a,b);
	return 1;
}

Compilation message

parks.cpp: In function 'int construct_roads(std::vector<int>, std::vector<int>)':
parks.cpp:26:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |     for(int i=0;i<x.size();i++)
      |                 ~^~~~~~~~~
parks.cpp:30:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |  for(int i=0;i<x.size();i++)
      |              ~^~~~~~~~~
parks.cpp:50:8: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   50 |  if(cnt!=x.size())return 0;
      |     ~~~^~~~~~~~~~
parks.cpp:55:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |  for(int i=0;i<roads.size();i++)
      |              ~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 4940 KB Output is correct
2 Correct 3 ms 4940 KB Output is correct
3 Correct 3 ms 4940 KB Output is correct
4 Correct 4 ms 4996 KB Output is correct
5 Correct 3 ms 4940 KB Output is correct
6 Correct 3 ms 4940 KB Output is correct
7 Correct 3 ms 4940 KB Output is correct
8 Correct 3 ms 4940 KB Output is correct
9 Correct 212 ms 31192 KB Output is correct
10 Correct 17 ms 7756 KB Output is correct
11 Correct 89 ms 19220 KB Output is correct
12 Correct 25 ms 9056 KB Output is correct
13 Correct 56 ms 12868 KB Output is correct
14 Correct 4 ms 5068 KB Output is correct
15 Correct 5 ms 5264 KB Output is correct
16 Correct 230 ms 27940 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 4940 KB Output is correct
2 Correct 3 ms 4940 KB Output is correct
3 Correct 3 ms 4940 KB Output is correct
4 Correct 4 ms 4996 KB Output is correct
5 Correct 3 ms 4940 KB Output is correct
6 Correct 3 ms 4940 KB Output is correct
7 Correct 3 ms 4940 KB Output is correct
8 Correct 3 ms 4940 KB Output is correct
9 Correct 212 ms 31192 KB Output is correct
10 Correct 17 ms 7756 KB Output is correct
11 Correct 89 ms 19220 KB Output is correct
12 Correct 25 ms 9056 KB Output is correct
13 Correct 56 ms 12868 KB Output is correct
14 Correct 4 ms 5068 KB Output is correct
15 Correct 5 ms 5264 KB Output is correct
16 Correct 230 ms 27940 KB Output is correct
17 Incorrect 3 ms 4996 KB Tree @(3, 3) appears more than once: for edges on positions 0 and 2
18 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 4940 KB Output is correct
2 Correct 3 ms 4940 KB Output is correct
3 Correct 3 ms 4940 KB Output is correct
4 Correct 4 ms 4996 KB Output is correct
5 Correct 3 ms 4940 KB Output is correct
6 Correct 3 ms 4940 KB Output is correct
7 Correct 3 ms 4940 KB Output is correct
8 Correct 3 ms 4940 KB Output is correct
9 Correct 212 ms 31192 KB Output is correct
10 Correct 17 ms 7756 KB Output is correct
11 Correct 89 ms 19220 KB Output is correct
12 Correct 25 ms 9056 KB Output is correct
13 Correct 56 ms 12868 KB Output is correct
14 Correct 4 ms 5068 KB Output is correct
15 Correct 5 ms 5264 KB Output is correct
16 Correct 230 ms 27940 KB Output is correct
17 Incorrect 3 ms 4996 KB Tree @(3, 3) appears more than once: for edges on positions 0 and 2
18 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 4940 KB Output is correct
2 Correct 3 ms 4940 KB Output is correct
3 Correct 3 ms 4940 KB Output is correct
4 Correct 4 ms 4996 KB Output is correct
5 Correct 3 ms 4940 KB Output is correct
6 Correct 3 ms 4940 KB Output is correct
7 Correct 3 ms 4940 KB Output is correct
8 Correct 3 ms 4940 KB Output is correct
9 Correct 212 ms 31192 KB Output is correct
10 Correct 17 ms 7756 KB Output is correct
11 Correct 89 ms 19220 KB Output is correct
12 Correct 25 ms 9056 KB Output is correct
13 Correct 56 ms 12868 KB Output is correct
14 Correct 4 ms 5068 KB Output is correct
15 Correct 5 ms 5264 KB Output is correct
16 Correct 230 ms 27940 KB Output is correct
17 Correct 3 ms 4940 KB Output is correct
18 Correct 4 ms 4940 KB Output is correct
19 Correct 4 ms 4940 KB Output is correct
20 Correct 697 ms 59924 KB Output is correct
21 Correct 785 ms 56688 KB Output is correct
22 Correct 710 ms 54968 KB Output is correct
23 Correct 521 ms 47000 KB Output is correct
24 Correct 358 ms 22596 KB Output is correct
25 Correct 652 ms 28760 KB Output is correct
26 Correct 529 ms 28632 KB Output is correct
27 Correct 638 ms 43280 KB Output is correct
28 Correct 612 ms 43280 KB Output is correct
29 Correct 766 ms 43188 KB Output is correct
30 Correct 706 ms 43184 KB Output is correct
31 Correct 3 ms 4992 KB Output is correct
32 Correct 39 ms 8412 KB Output is correct
33 Correct 137 ms 14124 KB Output is correct
34 Correct 615 ms 57628 KB Output is correct
35 Correct 19 ms 6280 KB Output is correct
36 Correct 115 ms 11276 KB Output is correct
37 Correct 258 ms 17428 KB Output is correct
38 Correct 236 ms 21380 KB Output is correct
39 Correct 402 ms 26696 KB Output is correct
40 Correct 477 ms 33824 KB Output is correct
41 Correct 631 ms 39480 KB Output is correct
42 Correct 802 ms 45032 KB Output is correct
43 Correct 4 ms 4940 KB Output is correct
44 Correct 3 ms 4940 KB Output is correct
45 Correct 4 ms 4940 KB Output is correct
46 Correct 3 ms 4940 KB Output is correct
47 Correct 3 ms 4940 KB Output is correct
48 Correct 3 ms 4940 KB Output is correct
49 Correct 3 ms 4940 KB Output is correct
50 Correct 3 ms 4996 KB Output is correct
51 Correct 3 ms 4940 KB Output is correct
52 Correct 3 ms 4940 KB Output is correct
53 Correct 3 ms 4940 KB Output is correct
54 Correct 5 ms 5196 KB Output is correct
55 Correct 6 ms 5324 KB Output is correct
56 Correct 245 ms 28900 KB Output is correct
57 Correct 396 ms 40924 KB Output is correct
58 Correct 432 ms 40460 KB Output is correct
59 Correct 3 ms 4940 KB Output is correct
60 Correct 3 ms 4940 KB Output is correct
61 Correct 3 ms 4940 KB Output is correct
62 Correct 531 ms 54236 KB Output is correct
63 Correct 639 ms 54544 KB Output is correct
64 Correct 548 ms 55992 KB Output is correct
65 Correct 8 ms 5452 KB Output is correct
66 Correct 15 ms 5972 KB Output is correct
67 Correct 266 ms 26408 KB Output is correct
68 Correct 536 ms 40188 KB Output is correct
69 Correct 668 ms 48460 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 4940 KB Output is correct
2 Correct 3 ms 4940 KB Output is correct
3 Correct 3 ms 4940 KB Output is correct
4 Correct 4 ms 4996 KB Output is correct
5 Correct 3 ms 4940 KB Output is correct
6 Correct 3 ms 4940 KB Output is correct
7 Correct 3 ms 4940 KB Output is correct
8 Correct 3 ms 4940 KB Output is correct
9 Correct 212 ms 31192 KB Output is correct
10 Correct 17 ms 7756 KB Output is correct
11 Correct 89 ms 19220 KB Output is correct
12 Correct 25 ms 9056 KB Output is correct
13 Correct 56 ms 12868 KB Output is correct
14 Correct 4 ms 5068 KB Output is correct
15 Correct 5 ms 5264 KB Output is correct
16 Correct 230 ms 27940 KB Output is correct
17 Correct 574 ms 59540 KB Output is correct
18 Correct 593 ms 53632 KB Output is correct
19 Correct 658 ms 60048 KB Output is correct
20 Correct 776 ms 49864 KB Output is correct
21 Correct 611 ms 44364 KB Output is correct
22 Correct 3 ms 4940 KB Output is correct
23 Correct 74 ms 11784 KB Output is correct
24 Correct 37 ms 7876 KB Output is correct
25 Correct 146 ms 14044 KB Output is correct
26 Correct 332 ms 20276 KB Output is correct
27 Correct 306 ms 28268 KB Output is correct
28 Correct 425 ms 33888 KB Output is correct
29 Correct 486 ms 39708 KB Output is correct
30 Correct 591 ms 45864 KB Output is correct
31 Correct 724 ms 49576 KB Output is correct
32 Correct 641 ms 55700 KB Output is correct
33 Correct 578 ms 58764 KB Output is correct
34 Correct 11 ms 5708 KB Output is correct
35 Correct 16 ms 6224 KB Output is correct
36 Correct 274 ms 26892 KB Output is correct
37 Correct 520 ms 39444 KB Output is correct
38 Correct 695 ms 50056 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 4940 KB Output is correct
2 Correct 3 ms 4940 KB Output is correct
3 Correct 3 ms 4940 KB Output is correct
4 Correct 4 ms 4996 KB Output is correct
5 Correct 3 ms 4940 KB Output is correct
6 Correct 3 ms 4940 KB Output is correct
7 Correct 3 ms 4940 KB Output is correct
8 Correct 3 ms 4940 KB Output is correct
9 Correct 212 ms 31192 KB Output is correct
10 Correct 17 ms 7756 KB Output is correct
11 Correct 89 ms 19220 KB Output is correct
12 Correct 25 ms 9056 KB Output is correct
13 Correct 56 ms 12868 KB Output is correct
14 Correct 4 ms 5068 KB Output is correct
15 Correct 5 ms 5264 KB Output is correct
16 Correct 230 ms 27940 KB Output is correct
17 Incorrect 3 ms 4996 KB Tree @(3, 3) appears more than once: for edges on positions 0 and 2
18 Halted 0 ms 0 KB -