답안 #1040841

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1040841 2024-08-01T10:34:10 Z Dan4Life 분수 공원 (IOI21_parks) C++17
70 / 100
313 ms 121612 KB
#include "parks.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define sz(a) (int)a.size()
#define all(a) begin(a),end(a)
using vi = vector<int>;
using ll = long long;
using ar2 = array<int,2>;
using ar3 = array<int,3>;

const int mxN = (int)2e5+10;
int n;
struct Edge{
	int fa, fb, x, y;
	Edge(int a=0, int b=0, int _x=-1, int _y=-1){
		fa=a, fb=b, x=_x, y=_y;
	}
};
vector<Edge> edges;
vector<ar3> fountains, origFountains;
vector<int> adj[mxN];
set<ar2> usedB;

template<int SZ> struct DSU{
	int p[SZ];
	vector<int> comp[SZ];
	void init(int n){
		for(int i = 0; i < n; i++){
			p[i]=i; comp[i].clear();
			comp[i].pb(i);
		}
	}
	
	int findSet(int i){return p[i]==i?i:p[i]=findSet(p[i]);}
	bool isSameSet(int i, int j) {return findSet(i)==findSet(j);}
	void unionSet(int i, int j){
		int x = findSet(i), y = findSet(j);
		if(x==y) return;
		adj[i].pb(j); adj[j].pb(i);
		if(sz(comp[x]) < sz(comp[y])) swap(x,y);
		p[y]=x; for(auto u : comp[y]) comp[x].pb(u);
	}
	int findSz(int i) { return sz(comp[findSet(i)]); }
};
DSU<mxN> dsu;

set<int> horEdge[mxN], verEdge[mxN];

void dfs(int s, int p, bool turn){
	if(p!=-1){
		if(origFountains[s][0]==origFountains[p][0]){
			int x = origFountains[s][0], y = min(origFountains[s][1],origFountains[p][1])+1;
			int x1 = x-1, x2 = x+1;
			if(!turn) verEdge[x].insert(y-1);
			else{
				bool ok = 0;
				if(horEdge[y-1].count(x-2) and usedB.count({x1,y-2})) ok=1;
				if(horEdge[y+1].count(x-2) and usedB.count({x1,y+2})) ok=1;
				if(ok) swap(x1,x2);
				
				if(usedB.count({x1,y})) swap(x1,x2);
				if(usedB.count({x1,y})){ dsu.init(n); return; }
				edges.pb(Edge(s,p,x1,y)); usedB.insert({x1,y});
				verEdge[x].erase(y-1);
			}
		}
		else{
			int x = min(origFountains[s][0],origFountains[p][0])+1, y = origFountains[s][1];
			int y1 = y-1, y2 = y+1;
			if(!turn) horEdge[y].insert(x-1);
			else{
				bool ok = 0;
				if(verEdge[x-1].count(y-2) and usedB.count({x-2,y1})) ok=1;
				if(verEdge[x+1].count(y-2) and usedB.count({x+2,y1})) ok=1;
				if(ok) swap(y1,y2);
				
				if(usedB.count({x,y1})) swap(y1,y2);
				if(usedB.count({x,y1})){ dsu.init(n); return; }
				edges.pb(Edge(s,p,x,y1)); usedB.insert({x,y1});
				horEdge[y].erase(x-1);
			}
		}
	}
	for(auto u : adj[s]){
		if(u==p) continue;
		dfs(u,s,turn);
	}
}

int construct_roads(vi x, vi y) {
	n = sz(x); dsu.init(n);
	if (n==1){ build({}, {}, {}, {}); return 1; }
	int mnX = *min_element(all(x));
	int mxX = *max_element(all(x));
	for(int i = 0; i < n; i++){
		fountains.pb({x[i],y[i],i});
		origFountains.pb({x[i],y[i],i});
	}
	
	if(mnX==mxX){
		sort(all(fountains),[&](ar3 a, ar3 b){ return a[1]<b[1]; });
		for(int i = 1; i < sz(fountains); i++){
			if(fountains[i][1]-fountains[i-1][1]==2){
				auto [x1,y1,a] = fountains[i-1];
				auto [x2,y2,b] = fountains[i];
				dsu.unionSet(a,b);
				edges.pb(Edge(a,b,x1-1,y1+1));
			}
		}
	}
	else if(mxX-mnX==2){
		sort(all(fountains),[&](ar3 a, ar3 b){ 
			if(a[0]!=b[0]) return a[0]<b[0];
			return a[1]<b[1]; 
		});
		set<ar2> S; S.clear();
		for(int i = sz(fountains)-1; i>=0; i--){
			if(fountains[i][0]!=mxX) break;
			S.insert({fountains[i][1], fountains[i][2]});
		}
		for(int i = 1; i < sz(fountains); i++){
			if(fountains[i][0]!=fountains[i-1][0]) continue;
			if(fountains[i][1]-fountains[i-1][1]==2){
				auto [x1,y1,a] = fountains[i-1];
				auto [x2,y2,b] = fountains[i];
				dsu.unionSet(a,b);
				if(x1==mnX) edges.pb(Edge(a,b,x1-1,y1+1));
				else edges.pb(Edge(a,b,x1+1,y1+1));
			}
		}
		
		for(int i = 0; i < sz(fountains); i++){
			auto [x1,y1,a] = fountains[i];
			if(x1!=mnX) break;
			auto itr = S.lower_bound({y1,-1});
			if(itr==end(S) or (*itr)[0]!=y1) continue;
			int b = (*itr)[1];
			dsu.unionSet(a,b);
			edges.pb(Edge(a,b,x1+1,y1-1));
		}
	}
	else if(mxX-mnX==4){
		sort(all(fountains),[&](ar3 a, ar3 b){ 
			if(a[0]!=b[0]) return a[0]<b[0];
			return a[1]<b[1]; 
		});
		set<ar2> S[mxN];
		for(int i = sz(fountains)-1; i>=0; i--)
			S[fountains[i][0]].insert({fountains[i][1], fountains[i][2]});
		for(int i = 1; i < sz(fountains); i++){
			if(fountains[i][0]!=fountains[i-1][0]) continue;
			if(fountains[i][1]-fountains[i-1][1]==2){
				auto [x1,y1,a] = fountains[i-1];
				auto [x2,y2,b] = fountains[i];
				dsu.unionSet(a,b);
				if(x1==mnX) edges.pb(Edge(a,b,x1-1,y1+1)), usedB.insert({x1-1,y1+1});
				else if(x1==mxX) edges.pb(Edge(a,b,x1+1,y1+1)), usedB.insert({x1+1,y1+1});
				else edges.pb(Edge(a,b,y1%4==0?x1-1:x1+1,y1+1)), usedB.insert({y1%4==0?x1-1:x1+1,y1+1});
			}
		}
		for(int i = 0; i < sz(fountains); i++){
			auto [x1,y1,a] = fountains[i];
			auto itr = S[x1+2].lower_bound({y1,-1});
			if(itr==end(S[x1+2]) or (*itr)[0]!=y1) continue;
			int b = (*itr)[1];
			
			if(!usedB.count({x1+1,y1-1})){
				dsu.unionSet(a,b);
				edges.pb(Edge(a,b,x1+1,y1-1));
				usedB.insert({x1+1,y1-1});
			}
			else if(!usedB.count({x1+1,y1+1})){
				dsu.unionSet(a,b);
				edges.pb(Edge(a,b,x1+1,y1+1));
				usedB.insert({x1+1,y1+1});
			}			
		}
	}
	else{
		sort(all(fountains),[&](ar3 a, ar3 b){ 
			if(a[0]!=b[0]) return a[0]<b[0];
			return a[1]<b[1]; 
		});
		set<ar2> S[mxN];
		for(int i = sz(fountains)-1; i>=0; i--)
			S[fountains[i][0]].insert({fountains[i][1], fountains[i][2]});
		for(int i = 1; i < sz(fountains); i++){
			if(fountains[i][0]!=fountains[i-1][0]) continue;
			if(fountains[i][1]-fountains[i-1][1]==2){
				auto [x1,y1,a] = fountains[i-1];
				auto [x2,y2,b] = fountains[i];
				dsu.unionSet(a,b);
			}
		}
		for(int i = 0; i < sz(fountains); i++){
			auto [x1,y1,a] = fountains[i];
			auto itr = S[x1+2].lower_bound({y1,-1});
			if(itr==end(S[x1+2]) or (*itr)[0]!=y1) continue;
			int b = (*itr)[1];
			dsu.unionSet(a,b);
		}
		for(int i = 0; i < n; i++){
			if(sz(adj[i])!=1) continue;
			dfs(i,-1, 0); dfs(i,-1, 1); break;
		}
	}
	if(dsu.findSz(0)!=n) return 0;
    vi U, V, A, B;
    for(auto edge : edges){
		U.pb(edge.fa), V.pb(edge.fb);
		A.pb(edge.x), B.pb(edge.y);
	}
	build(U,V,A,B); return 1;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 38744 KB Output is correct
2 Correct 8 ms 38744 KB Output is correct
3 Correct 7 ms 38748 KB Output is correct
4 Correct 8 ms 38748 KB Output is correct
5 Correct 8 ms 38748 KB Output is correct
6 Correct 7 ms 38748 KB Output is correct
7 Correct 8 ms 38568 KB Output is correct
8 Correct 8 ms 38748 KB Output is correct
9 Correct 58 ms 57236 KB Output is correct
10 Correct 12 ms 40536 KB Output is correct
11 Correct 27 ms 48540 KB Output is correct
12 Correct 13 ms 41560 KB Output is correct
13 Correct 17 ms 44108 KB Output is correct
14 Correct 8 ms 38748 KB Output is correct
15 Correct 9 ms 38896 KB Output is correct
16 Correct 59 ms 57120 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 38744 KB Output is correct
2 Correct 8 ms 38744 KB Output is correct
3 Correct 7 ms 38748 KB Output is correct
4 Correct 8 ms 38748 KB Output is correct
5 Correct 8 ms 38748 KB Output is correct
6 Correct 7 ms 38748 KB Output is correct
7 Correct 8 ms 38568 KB Output is correct
8 Correct 8 ms 38748 KB Output is correct
9 Correct 58 ms 57236 KB Output is correct
10 Correct 12 ms 40536 KB Output is correct
11 Correct 27 ms 48540 KB Output is correct
12 Correct 13 ms 41560 KB Output is correct
13 Correct 17 ms 44108 KB Output is correct
14 Correct 8 ms 38748 KB Output is correct
15 Correct 9 ms 38896 KB Output is correct
16 Correct 59 ms 57120 KB Output is correct
17 Correct 11 ms 38744 KB Output is correct
18 Correct 8 ms 38748 KB Output is correct
19 Correct 8 ms 38740 KB Output is correct
20 Correct 8 ms 38696 KB Output is correct
21 Correct 8 ms 38748 KB Output is correct
22 Correct 8 ms 38748 KB Output is correct
23 Correct 162 ms 88584 KB Output is correct
24 Correct 8 ms 38744 KB Output is correct
25 Correct 8 ms 39000 KB Output is correct
26 Correct 9 ms 39184 KB Output is correct
27 Correct 9 ms 39260 KB Output is correct
28 Correct 64 ms 57864 KB Output is correct
29 Correct 92 ms 67456 KB Output is correct
30 Correct 175 ms 78080 KB Output is correct
31 Correct 158 ms 89604 KB Output is correct
32 Correct 8 ms 38744 KB Output is correct
33 Correct 8 ms 38748 KB Output is correct
34 Correct 8 ms 38584 KB Output is correct
35 Correct 8 ms 38748 KB Output is correct
36 Correct 9 ms 38748 KB Output is correct
37 Correct 10 ms 38748 KB Output is correct
38 Correct 8 ms 38748 KB Output is correct
39 Correct 10 ms 38744 KB Output is correct
40 Correct 9 ms 38620 KB Output is correct
41 Correct 11 ms 38552 KB Output is correct
42 Correct 8 ms 38700 KB Output is correct
43 Correct 10 ms 39004 KB Output is correct
44 Correct 9 ms 39212 KB Output is correct
45 Correct 87 ms 57872 KB Output is correct
46 Correct 125 ms 68628 KB Output is correct
47 Correct 117 ms 69504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 38744 KB Output is correct
2 Correct 8 ms 38744 KB Output is correct
3 Correct 7 ms 38748 KB Output is correct
4 Correct 8 ms 38748 KB Output is correct
5 Correct 8 ms 38748 KB Output is correct
6 Correct 7 ms 38748 KB Output is correct
7 Correct 8 ms 38568 KB Output is correct
8 Correct 8 ms 38748 KB Output is correct
9 Correct 58 ms 57236 KB Output is correct
10 Correct 12 ms 40536 KB Output is correct
11 Correct 27 ms 48540 KB Output is correct
12 Correct 13 ms 41560 KB Output is correct
13 Correct 17 ms 44108 KB Output is correct
14 Correct 8 ms 38748 KB Output is correct
15 Correct 9 ms 38896 KB Output is correct
16 Correct 59 ms 57120 KB Output is correct
17 Correct 11 ms 38744 KB Output is correct
18 Correct 8 ms 38748 KB Output is correct
19 Correct 8 ms 38740 KB Output is correct
20 Correct 8 ms 38696 KB Output is correct
21 Correct 8 ms 38748 KB Output is correct
22 Correct 8 ms 38748 KB Output is correct
23 Correct 162 ms 88584 KB Output is correct
24 Correct 8 ms 38744 KB Output is correct
25 Correct 8 ms 39000 KB Output is correct
26 Correct 9 ms 39184 KB Output is correct
27 Correct 9 ms 39260 KB Output is correct
28 Correct 64 ms 57864 KB Output is correct
29 Correct 92 ms 67456 KB Output is correct
30 Correct 175 ms 78080 KB Output is correct
31 Correct 158 ms 89604 KB Output is correct
32 Correct 8 ms 38744 KB Output is correct
33 Correct 8 ms 38748 KB Output is correct
34 Correct 8 ms 38584 KB Output is correct
35 Correct 8 ms 38748 KB Output is correct
36 Correct 9 ms 38748 KB Output is correct
37 Correct 10 ms 38748 KB Output is correct
38 Correct 8 ms 38748 KB Output is correct
39 Correct 10 ms 38744 KB Output is correct
40 Correct 9 ms 38620 KB Output is correct
41 Correct 11 ms 38552 KB Output is correct
42 Correct 8 ms 38700 KB Output is correct
43 Correct 10 ms 39004 KB Output is correct
44 Correct 9 ms 39212 KB Output is correct
45 Correct 87 ms 57872 KB Output is correct
46 Correct 125 ms 68628 KB Output is correct
47 Correct 117 ms 69504 KB Output is correct
48 Correct 8 ms 38748 KB Output is correct
49 Correct 9 ms 38576 KB Output is correct
50 Correct 10 ms 38748 KB Output is correct
51 Correct 9 ms 38604 KB Output is correct
52 Correct 11 ms 38584 KB Output is correct
53 Correct 9 ms 38704 KB Output is correct
54 Correct 11 ms 38792 KB Output is correct
55 Correct 258 ms 98048 KB Output is correct
56 Correct 10 ms 38656 KB Output is correct
57 Correct 14 ms 39256 KB Output is correct
58 Correct 16 ms 40540 KB Output is correct
59 Correct 18 ms 41084 KB Output is correct
60 Correct 133 ms 68964 KB Output is correct
61 Correct 181 ms 80776 KB Output is correct
62 Correct 191 ms 88856 KB Output is correct
63 Correct 256 ms 99848 KB Output is correct
64 Correct 11 ms 38744 KB Output is correct
65 Correct 8 ms 38620 KB Output is correct
66 Correct 9 ms 38748 KB Output is correct
67 Correct 200 ms 90152 KB Output is correct
68 Correct 208 ms 90632 KB Output is correct
69 Correct 178 ms 89644 KB Output is correct
70 Correct 12 ms 39516 KB Output is correct
71 Correct 15 ms 40540 KB Output is correct
72 Correct 126 ms 63364 KB Output is correct
73 Correct 174 ms 79156 KB Output is correct
74 Correct 222 ms 88596 KB Output is correct
75 Correct 223 ms 92680 KB Output is correct
76 Correct 186 ms 90236 KB Output is correct
77 Correct 11 ms 40028 KB Output is correct
78 Correct 16 ms 40796 KB Output is correct
79 Correct 115 ms 64948 KB Output is correct
80 Correct 208 ms 81300 KB Output is correct
81 Correct 239 ms 92176 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 38744 KB Output is correct
2 Correct 8 ms 38744 KB Output is correct
3 Correct 7 ms 38748 KB Output is correct
4 Correct 8 ms 38748 KB Output is correct
5 Correct 8 ms 38748 KB Output is correct
6 Correct 7 ms 38748 KB Output is correct
7 Correct 8 ms 38568 KB Output is correct
8 Correct 8 ms 38748 KB Output is correct
9 Correct 58 ms 57236 KB Output is correct
10 Correct 12 ms 40536 KB Output is correct
11 Correct 27 ms 48540 KB Output is correct
12 Correct 13 ms 41560 KB Output is correct
13 Correct 17 ms 44108 KB Output is correct
14 Correct 8 ms 38748 KB Output is correct
15 Correct 9 ms 38896 KB Output is correct
16 Correct 59 ms 57120 KB Output is correct
17 Correct 8 ms 38744 KB Output is correct
18 Correct 7 ms 38748 KB Output is correct
19 Correct 12 ms 38748 KB Output is correct
20 Correct 303 ms 119540 KB Output is correct
21 Correct 313 ms 118768 KB Output is correct
22 Correct 282 ms 120332 KB Output is correct
23 Correct 227 ms 109184 KB Output is correct
24 Correct 67 ms 62420 KB Output is correct
25 Correct 122 ms 69676 KB Output is correct
26 Correct 106 ms 69932 KB Output is correct
27 Correct 239 ms 87868 KB Output is correct
28 Correct 223 ms 88840 KB Output is correct
29 Correct 244 ms 86796 KB Output is correct
30 Correct 241 ms 87816 KB Output is correct
31 Correct 13 ms 38748 KB Output is correct
32 Correct 26 ms 43112 KB Output is correct
33 Correct 37 ms 50500 KB Output is correct
34 Correct 293 ms 118796 KB Output is correct
35 Correct 16 ms 40664 KB Output is correct
36 Correct 40 ms 47616 KB Output is correct
37 Correct 75 ms 55616 KB Output is correct
38 Correct 110 ms 59324 KB Output is correct
39 Correct 168 ms 66264 KB Output is correct
40 Correct 238 ms 76964 KB Output is correct
41 Correct 298 ms 83956 KB Output is correct
42 Correct 305 ms 89684 KB Output is correct
43 Correct 8 ms 38748 KB Output is correct
44 Correct 9 ms 38748 KB Output is correct
45 Correct 8 ms 38564 KB Output is correct
46 Correct 10 ms 38680 KB Output is correct
47 Correct 8 ms 38748 KB Output is correct
48 Correct 8 ms 38748 KB Output is correct
49 Correct 8 ms 38748 KB Output is correct
50 Correct 10 ms 38748 KB Output is correct
51 Correct 8 ms 38748 KB Output is correct
52 Correct 9 ms 38744 KB Output is correct
53 Correct 10 ms 38612 KB Output is correct
54 Correct 11 ms 39000 KB Output is correct
55 Correct 10 ms 39264 KB Output is correct
56 Correct 69 ms 57988 KB Output is correct
57 Correct 121 ms 69560 KB Output is correct
58 Correct 109 ms 68552 KB Output is correct
59 Correct 9 ms 38744 KB Output is correct
60 Correct 10 ms 38772 KB Output is correct
61 Correct 8 ms 38748 KB Output is correct
62 Correct 204 ms 89100 KB Output is correct
63 Correct 214 ms 88504 KB Output is correct
64 Correct 211 ms 88344 KB Output is correct
65 Correct 11 ms 39516 KB Output is correct
66 Correct 18 ms 40540 KB Output is correct
67 Correct 126 ms 62520 KB Output is correct
68 Correct 150 ms 77316 KB Output is correct
69 Correct 203 ms 87304 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 38744 KB Output is correct
2 Correct 8 ms 38744 KB Output is correct
3 Correct 7 ms 38748 KB Output is correct
4 Correct 8 ms 38748 KB Output is correct
5 Correct 8 ms 38748 KB Output is correct
6 Correct 7 ms 38748 KB Output is correct
7 Correct 8 ms 38568 KB Output is correct
8 Correct 8 ms 38748 KB Output is correct
9 Correct 58 ms 57236 KB Output is correct
10 Correct 12 ms 40536 KB Output is correct
11 Correct 27 ms 48540 KB Output is correct
12 Correct 13 ms 41560 KB Output is correct
13 Correct 17 ms 44108 KB Output is correct
14 Correct 8 ms 38748 KB Output is correct
15 Correct 9 ms 38896 KB Output is correct
16 Correct 59 ms 57120 KB Output is correct
17 Correct 257 ms 119052 KB Output is correct
18 Correct 254 ms 112296 KB Output is correct
19 Correct 275 ms 119944 KB Output is correct
20 Correct 198 ms 87336 KB Output is correct
21 Correct 190 ms 82124 KB Output is correct
22 Correct 8 ms 38748 KB Output is correct
23 Correct 42 ms 46920 KB Output is correct
24 Correct 22 ms 42856 KB Output is correct
25 Correct 51 ms 50620 KB Output is correct
26 Correct 82 ms 58228 KB Output is correct
27 Correct 129 ms 63352 KB Output is correct
28 Correct 164 ms 69292 KB Output is correct
29 Correct 204 ms 78948 KB Output is correct
30 Correct 277 ms 83924 KB Output is correct
31 Correct 284 ms 89532 KB Output is correct
32 Correct 201 ms 90896 KB Output is correct
33 Correct 185 ms 88584 KB Output is correct
34 Correct 13 ms 39768 KB Output is correct
35 Correct 15 ms 40868 KB Output is correct
36 Correct 101 ms 64100 KB Output is correct
37 Correct 152 ms 80520 KB Output is correct
38 Correct 203 ms 89864 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 38744 KB Output is correct
2 Correct 8 ms 38744 KB Output is correct
3 Correct 7 ms 38748 KB Output is correct
4 Correct 8 ms 38748 KB Output is correct
5 Correct 8 ms 38748 KB Output is correct
6 Correct 7 ms 38748 KB Output is correct
7 Correct 8 ms 38568 KB Output is correct
8 Correct 8 ms 38748 KB Output is correct
9 Correct 58 ms 57236 KB Output is correct
10 Correct 12 ms 40536 KB Output is correct
11 Correct 27 ms 48540 KB Output is correct
12 Correct 13 ms 41560 KB Output is correct
13 Correct 17 ms 44108 KB Output is correct
14 Correct 8 ms 38748 KB Output is correct
15 Correct 9 ms 38896 KB Output is correct
16 Correct 59 ms 57120 KB Output is correct
17 Correct 11 ms 38744 KB Output is correct
18 Correct 8 ms 38748 KB Output is correct
19 Correct 8 ms 38740 KB Output is correct
20 Correct 8 ms 38696 KB Output is correct
21 Correct 8 ms 38748 KB Output is correct
22 Correct 8 ms 38748 KB Output is correct
23 Correct 162 ms 88584 KB Output is correct
24 Correct 8 ms 38744 KB Output is correct
25 Correct 8 ms 39000 KB Output is correct
26 Correct 9 ms 39184 KB Output is correct
27 Correct 9 ms 39260 KB Output is correct
28 Correct 64 ms 57864 KB Output is correct
29 Correct 92 ms 67456 KB Output is correct
30 Correct 175 ms 78080 KB Output is correct
31 Correct 158 ms 89604 KB Output is correct
32 Correct 8 ms 38744 KB Output is correct
33 Correct 8 ms 38748 KB Output is correct
34 Correct 8 ms 38584 KB Output is correct
35 Correct 8 ms 38748 KB Output is correct
36 Correct 9 ms 38748 KB Output is correct
37 Correct 10 ms 38748 KB Output is correct
38 Correct 8 ms 38748 KB Output is correct
39 Correct 10 ms 38744 KB Output is correct
40 Correct 9 ms 38620 KB Output is correct
41 Correct 11 ms 38552 KB Output is correct
42 Correct 8 ms 38700 KB Output is correct
43 Correct 10 ms 39004 KB Output is correct
44 Correct 9 ms 39212 KB Output is correct
45 Correct 87 ms 57872 KB Output is correct
46 Correct 125 ms 68628 KB Output is correct
47 Correct 117 ms 69504 KB Output is correct
48 Correct 8 ms 38748 KB Output is correct
49 Correct 9 ms 38576 KB Output is correct
50 Correct 10 ms 38748 KB Output is correct
51 Correct 9 ms 38604 KB Output is correct
52 Correct 11 ms 38584 KB Output is correct
53 Correct 9 ms 38704 KB Output is correct
54 Correct 11 ms 38792 KB Output is correct
55 Correct 258 ms 98048 KB Output is correct
56 Correct 10 ms 38656 KB Output is correct
57 Correct 14 ms 39256 KB Output is correct
58 Correct 16 ms 40540 KB Output is correct
59 Correct 18 ms 41084 KB Output is correct
60 Correct 133 ms 68964 KB Output is correct
61 Correct 181 ms 80776 KB Output is correct
62 Correct 191 ms 88856 KB Output is correct
63 Correct 256 ms 99848 KB Output is correct
64 Correct 11 ms 38744 KB Output is correct
65 Correct 8 ms 38620 KB Output is correct
66 Correct 9 ms 38748 KB Output is correct
67 Correct 200 ms 90152 KB Output is correct
68 Correct 208 ms 90632 KB Output is correct
69 Correct 178 ms 89644 KB Output is correct
70 Correct 12 ms 39516 KB Output is correct
71 Correct 15 ms 40540 KB Output is correct
72 Correct 126 ms 63364 KB Output is correct
73 Correct 174 ms 79156 KB Output is correct
74 Correct 222 ms 88596 KB Output is correct
75 Correct 223 ms 92680 KB Output is correct
76 Correct 186 ms 90236 KB Output is correct
77 Correct 11 ms 40028 KB Output is correct
78 Correct 16 ms 40796 KB Output is correct
79 Correct 115 ms 64948 KB Output is correct
80 Correct 208 ms 81300 KB Output is correct
81 Correct 239 ms 92176 KB Output is correct
82 Correct 8 ms 38744 KB Output is correct
83 Correct 7 ms 38748 KB Output is correct
84 Correct 12 ms 38748 KB Output is correct
85 Correct 303 ms 119540 KB Output is correct
86 Correct 313 ms 118768 KB Output is correct
87 Correct 282 ms 120332 KB Output is correct
88 Correct 227 ms 109184 KB Output is correct
89 Correct 67 ms 62420 KB Output is correct
90 Correct 122 ms 69676 KB Output is correct
91 Correct 106 ms 69932 KB Output is correct
92 Correct 239 ms 87868 KB Output is correct
93 Correct 223 ms 88840 KB Output is correct
94 Correct 244 ms 86796 KB Output is correct
95 Correct 241 ms 87816 KB Output is correct
96 Correct 13 ms 38748 KB Output is correct
97 Correct 26 ms 43112 KB Output is correct
98 Correct 37 ms 50500 KB Output is correct
99 Correct 293 ms 118796 KB Output is correct
100 Correct 16 ms 40664 KB Output is correct
101 Correct 40 ms 47616 KB Output is correct
102 Correct 75 ms 55616 KB Output is correct
103 Correct 110 ms 59324 KB Output is correct
104 Correct 168 ms 66264 KB Output is correct
105 Correct 238 ms 76964 KB Output is correct
106 Correct 298 ms 83956 KB Output is correct
107 Correct 305 ms 89684 KB Output is correct
108 Correct 8 ms 38748 KB Output is correct
109 Correct 9 ms 38748 KB Output is correct
110 Correct 8 ms 38564 KB Output is correct
111 Correct 10 ms 38680 KB Output is correct
112 Correct 8 ms 38748 KB Output is correct
113 Correct 8 ms 38748 KB Output is correct
114 Correct 8 ms 38748 KB Output is correct
115 Correct 10 ms 38748 KB Output is correct
116 Correct 8 ms 38748 KB Output is correct
117 Correct 9 ms 38744 KB Output is correct
118 Correct 10 ms 38612 KB Output is correct
119 Correct 11 ms 39000 KB Output is correct
120 Correct 10 ms 39264 KB Output is correct
121 Correct 69 ms 57988 KB Output is correct
122 Correct 121 ms 69560 KB Output is correct
123 Correct 109 ms 68552 KB Output is correct
124 Correct 9 ms 38744 KB Output is correct
125 Correct 10 ms 38772 KB Output is correct
126 Correct 8 ms 38748 KB Output is correct
127 Correct 204 ms 89100 KB Output is correct
128 Correct 214 ms 88504 KB Output is correct
129 Correct 211 ms 88344 KB Output is correct
130 Correct 11 ms 39516 KB Output is correct
131 Correct 18 ms 40540 KB Output is correct
132 Correct 126 ms 62520 KB Output is correct
133 Correct 150 ms 77316 KB Output is correct
134 Correct 203 ms 87304 KB Output is correct
135 Correct 257 ms 119052 KB Output is correct
136 Correct 254 ms 112296 KB Output is correct
137 Correct 275 ms 119944 KB Output is correct
138 Correct 198 ms 87336 KB Output is correct
139 Correct 190 ms 82124 KB Output is correct
140 Correct 8 ms 38748 KB Output is correct
141 Correct 42 ms 46920 KB Output is correct
142 Correct 22 ms 42856 KB Output is correct
143 Correct 51 ms 50620 KB Output is correct
144 Correct 82 ms 58228 KB Output is correct
145 Correct 129 ms 63352 KB Output is correct
146 Correct 164 ms 69292 KB Output is correct
147 Correct 204 ms 78948 KB Output is correct
148 Correct 277 ms 83924 KB Output is correct
149 Correct 284 ms 89532 KB Output is correct
150 Correct 201 ms 90896 KB Output is correct
151 Correct 185 ms 88584 KB Output is correct
152 Correct 13 ms 39768 KB Output is correct
153 Correct 15 ms 40868 KB Output is correct
154 Correct 101 ms 64100 KB Output is correct
155 Correct 152 ms 80520 KB Output is correct
156 Correct 203 ms 89864 KB Output is correct
157 Correct 10 ms 38748 KB Output is correct
158 Correct 8 ms 38748 KB Output is correct
159 Correct 8 ms 38744 KB Output is correct
160 Correct 8 ms 38632 KB Output is correct
161 Correct 225 ms 90376 KB Output is correct
162 Correct 271 ms 121612 KB Output is correct
163 Correct 235 ms 102916 KB Output is correct
164 Correct 230 ms 101640 KB Output is correct
165 Correct 207 ms 93964 KB Output is correct
166 Correct 221 ms 92168 KB Output is correct
167 Incorrect 42 ms 49228 KB Solution announced impossible, but it is possible.
168 Halted 0 ms 0 KB -