답안 #890739

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
890739 2023-12-21T20:55:38 Z amirhoseinfar1385 Jail (JOI22_jail) C++17
100 / 100
3949 ms 340920 KB
#include<bits/stdc++.h>
using namespace std;
const int maxn=120000+10,maxl=18;
vector<int>adj[maxn];
int res=1,n,m,timea=0,sz[maxn],alln[maxn],lca[maxl][maxn],ted[maxn],high[maxn],parh[maxn],vas[maxn];
pair<int,int>allq[maxn],stf[maxn];
int dfs(int u);
int kaf=(1<<18);

struct segment{
	set<int>st[(1<<19)];
	vector<int>v;
	void clear(){
		for(auto x:v){
			st[x].clear();
		}
		v.clear();
	}
	void add(int i,int l,int r,int tl,int tr,int w){
		if(l>r||l>tr||r<tl||tl>tr){
			return ;
		}
		if(l>=tl&&r<=tr){
			v.push_back(i);
			st[i].insert(w);
			return ;
		}
		int m=(l+r)>>1;
		add((i<<1),l,m,tl,tr,w);
		add((i<<1)^1,m+1,r,tl,tr,w);
		return ;	
	}
	void pors(int i,int w){
		if(i==0){
			return ;
		}
		int now=0;
		while(true){
			if((int)st[i].size()==0||(*st[i].rbegin())<=now){
				break;
			}
			auto x=*st[i].upper_bound(now);
			if(x==w){
				now=x;
				continue;
			}
			if(dfs(x)){
				st[i].erase(x);
			}
			now=x;
		}	
		pors((i>>1),w);
	}
}seg;

struct segmentn{
	set<int>st[(1<<19)];
	vector<int>v;
	void clear(){
		for(auto x:v){
			st[x].clear();
		}
		v.clear();
	}
	void add(int i,int w){
		if(i==0){
			return ;
		}
		v.push_back(i);
		st[i].insert(w);
		return add(i>>1,w);
	}
	void pors(int i,int l,int r,int tl,int tr,int w){
		if(l>r||l>tr||r<tl||tl>tr){
			return ;
		}
		if(l>=tl&&r<=tr){
			int now=0;
			while(true){
				if((int)st[i].size()==0||(*st[i].rbegin())<=now){
					break;
				}
				auto x=*st[i].upper_bound(now);
				if(x==w){
					now=x;
					continue;
				}
				if(dfs(x)){
					st[i].erase(x);
				}
				now=x;
			}	
			return ;
		}
		int m=(l+r)>>1;
		pors((i<<1),l,m,tl,tr,w);
		pors((i<<1)^1,m+1,r,tl,tr,w);
	}
}segn;

bool cmp(int a,int b){
	return sz[a]>sz[b];
}

int zird(int u,int v){
	return stf[v].first<=stf[u].first&&stf[v].second>=stf[u].second;
}

int getlca(int u,int v){
	if(zird(u,v)){
		return v;
	}
	if(zird(v,u)){
		return u;
	}
	for(int i=maxl-1;i>=0;i--){
		if(lca[i][u]!=0&&zird(v,lca[i][u])==0){
			u=lca[i][u];
		}
	}
	return lca[0][u];
}

void callca(){
	for(int i=1;i<maxl;i++){
		for(int j=1;j<=n;j++){
			lca[i][j]=lca[i-1][lca[i-1][j]];
		}
	}
}

void dfs1(int u=1,int par=0){
	lca[0][u]=par;
	sz[u]=1;
	for(auto x:adj[u]){
		if(x!=par){
			high[x]=high[u]+1;
			dfs1(x,u);
			sz[u]+=sz[x];
		}
	}
	if(u!=1){
		sort(adj[u].begin(),adj[u].end());
		adj[u].erase(lower_bound(adj[u].begin(),adj[u].end(),par));
	}
	sort(adj[u].begin(),adj[u].end(),cmp);
}

void dfs2(int u=1,int par=1){
	parh[u]=par;
	timea++;
	stf[u].first=timea;
	for(auto x:adj[u]){
		dfs2(x,x==adj[u][0]?par:x);
	}
	stf[u].second=timea;
}

void vorod(){
	segn.clear();
	seg.clear();
	timea=0;
	memset(vas,0,sizeof(vas));
	memset(ted,0,sizeof(ted));
	cin>>n;
	for(int i=1;i<=n;i++){
		adj[i].clear();
		alln[i]=-1;
	}
	for(int i=0;i<n-1;i++){
		int u,v;
		cin>>u>>v;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	cin>>m;
	for(int i=1;i<=m;i++){
		ted[i]=0;
		cin>>allq[i].first>>allq[i].second;
		alln[allq[i].first]=i;
		alln[allq[i].second]=i;
	}	
}

int dis(int u,int v){
	int uv=getlca(u,v);
	return high[u]+high[v]-2*high[uv];
}

int din(int uv,int u,int v){
	int a=dis(u,v),b=dis(uv,u),c=dis(uv,v);
	if(b+c==a){
		return 1;
	}
	return 0;
}

void go(int u,int had,int ind){
	////cout<<"in: "<<u<<" "<<had<<" "<<ind<<" "<<parh[u]<<" "<<lca[0][parh[u]]<<endl;
	if(zird(had,parh[u])){
		seg.add(1,0,kaf-1,stf[had].first+1,stf[u].first,ind);
		return ;
	}
	go(lca[0][parh[u]],had,ind);
	seg.add(1,0,kaf-1,stf[parh[u]].first,stf[u].first,ind);
}

void add(int u,int v,int ind){
	int uv=getlca(u,v);
	go(u,uv,ind);
	go(v,uv,ind);
	seg.add(1,0,kaf-1,stf[uv].first,stf[uv].first,ind);
}

void addn(int u,int ind){
	segn.add(stf[u].first+kaf,ind);
}

void gop(int u,int had,int ind){
	//cout<<"tof: "<<u<<" "<<had<<" "<<ind<<" "<<parh[u]<<" "<<stf[u].first<<" "<<stf[had].first<<" "<<stf[parh[u]].first<<endl;
	if(zird(had,parh[u])){
		segn.pors(1,0,kaf-1,stf[had].first,stf[u].first,ind);
		return ;
	}
	gop(lca[0][parh[u]],had,ind);
	segn.pors(1,0,kaf-1,stf[parh[u]].first,stf[u].first,ind);
}

void pors(int u,int v,int ind){
	int uv=getlca(u,v);
	gop(u,uv,ind);
	gop(v,uv,ind);
}

int dfs(int u){
	//cout<<"ins: "<<u<<endl;
	if(vas[u]==1){
		res=0;
		return 1;
	}
	if(vas[u]==2){
		return 1;
	}
	vas[u]=1;
	seg.pors(stf[allq[u].second].first+kaf,u);
	pors(allq[u].first,allq[u].second,u);
	vas[u]=2;
	//cout<<"out: "<<u<<endl;
	return 0;
}

void solve(){
	for(int i=1;i<=m;i++){
//		//cout<<"wtf "<<i<<endl;
		add(allq[i].first,allq[i].second,i);
//		//cout<<i<<endl;
		addn(allq[i].first,i);
//		//cout<<"by: "<<i<<endl;
	}
	////cout<<"salam"<<endl;
	res=1;
	for(int i=1;i<=m;i++){
		dfs(i);
	}
	if(res){
		cout<<"Yes\n";
	}
	else{
		cout<<"No\n";
	}
}	

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	//cout.tie(0);
	int t;
	cin>>t;
	for(int asd=0;asd<t;asd++){
		vorod();
		dfs1();
		dfs2();
		callca();
		solve();		
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 65624 KB Output is correct
2 Correct 12 ms 65628 KB Output is correct
3 Correct 12 ms 65624 KB Output is correct
4 Correct 28 ms 65628 KB Output is correct
5 Correct 51 ms 66380 KB Output is correct
6 Correct 13 ms 65740 KB Output is correct
7 Correct 17 ms 65628 KB Output is correct
8 Correct 18 ms 65908 KB Output is correct
9 Correct 64 ms 68180 KB Output is correct
10 Correct 49 ms 81264 KB Output is correct
11 Correct 44 ms 66044 KB Output is correct
12 Correct 122 ms 66644 KB Output is correct
13 Correct 354 ms 148104 KB Output is correct
14 Correct 364 ms 148916 KB Output is correct
15 Correct 927 ms 169812 KB Output is correct
16 Correct 2707 ms 299252 KB Output is correct
17 Correct 456 ms 192196 KB Output is correct
18 Correct 698 ms 214508 KB Output is correct
19 Correct 440 ms 186400 KB Output is correct
20 Correct 449 ms 186652 KB Output is correct
21 Correct 503 ms 200464 KB Output is correct
22 Correct 297 ms 145696 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 65624 KB Output is correct
2 Correct 12 ms 65628 KB Output is correct
3 Correct 14 ms 65628 KB Output is correct
4 Correct 14 ms 65664 KB Output is correct
5 Correct 13 ms 65624 KB Output is correct
6 Correct 13 ms 65628 KB Output is correct
7 Correct 13 ms 65628 KB Output is correct
8 Correct 14 ms 65884 KB Output is correct
9 Correct 13 ms 65628 KB Output is correct
10 Correct 15 ms 65624 KB Output is correct
11 Correct 13 ms 65628 KB Output is correct
12 Correct 13 ms 65628 KB Output is correct
13 Correct 14 ms 65704 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 65624 KB Output is correct
2 Correct 12 ms 65628 KB Output is correct
3 Correct 14 ms 65628 KB Output is correct
4 Correct 14 ms 65664 KB Output is correct
5 Correct 13 ms 65624 KB Output is correct
6 Correct 13 ms 65628 KB Output is correct
7 Correct 13 ms 65628 KB Output is correct
8 Correct 14 ms 65884 KB Output is correct
9 Correct 13 ms 65628 KB Output is correct
10 Correct 15 ms 65624 KB Output is correct
11 Correct 13 ms 65628 KB Output is correct
12 Correct 13 ms 65628 KB Output is correct
13 Correct 14 ms 65704 KB Output is correct
14 Correct 13 ms 65624 KB Output is correct
15 Correct 12 ms 65624 KB Output is correct
16 Correct 15 ms 65744 KB Output is correct
17 Correct 14 ms 65628 KB Output is correct
18 Correct 15 ms 65884 KB Output is correct
19 Correct 13 ms 65624 KB Output is correct
20 Correct 16 ms 65628 KB Output is correct
21 Correct 14 ms 65660 KB Output is correct
22 Correct 14 ms 65644 KB Output is correct
23 Correct 13 ms 65628 KB Output is correct
24 Correct 14 ms 65628 KB Output is correct
25 Correct 15 ms 65688 KB Output is correct
26 Correct 14 ms 65628 KB Output is correct
27 Correct 14 ms 65624 KB Output is correct
28 Correct 15 ms 65884 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 65624 KB Output is correct
2 Correct 12 ms 65628 KB Output is correct
3 Correct 14 ms 65628 KB Output is correct
4 Correct 14 ms 65664 KB Output is correct
5 Correct 13 ms 65624 KB Output is correct
6 Correct 13 ms 65628 KB Output is correct
7 Correct 13 ms 65628 KB Output is correct
8 Correct 14 ms 65884 KB Output is correct
9 Correct 13 ms 65628 KB Output is correct
10 Correct 15 ms 65624 KB Output is correct
11 Correct 13 ms 65628 KB Output is correct
12 Correct 13 ms 65628 KB Output is correct
13 Correct 14 ms 65704 KB Output is correct
14 Correct 13 ms 65624 KB Output is correct
15 Correct 12 ms 65624 KB Output is correct
16 Correct 15 ms 65744 KB Output is correct
17 Correct 14 ms 65628 KB Output is correct
18 Correct 15 ms 65884 KB Output is correct
19 Correct 13 ms 65624 KB Output is correct
20 Correct 16 ms 65628 KB Output is correct
21 Correct 14 ms 65660 KB Output is correct
22 Correct 14 ms 65644 KB Output is correct
23 Correct 13 ms 65628 KB Output is correct
24 Correct 14 ms 65628 KB Output is correct
25 Correct 15 ms 65688 KB Output is correct
26 Correct 14 ms 65628 KB Output is correct
27 Correct 14 ms 65624 KB Output is correct
28 Correct 15 ms 65884 KB Output is correct
29 Correct 17 ms 65880 KB Output is correct
30 Correct 17 ms 65624 KB Output is correct
31 Correct 16 ms 65884 KB Output is correct
32 Correct 16 ms 65604 KB Output is correct
33 Correct 15 ms 65628 KB Output is correct
34 Correct 19 ms 65668 KB Output is correct
35 Correct 20 ms 65840 KB Output is correct
36 Correct 18 ms 65884 KB Output is correct
37 Correct 17 ms 65828 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 65624 KB Output is correct
2 Correct 12 ms 65628 KB Output is correct
3 Correct 14 ms 65628 KB Output is correct
4 Correct 14 ms 65664 KB Output is correct
5 Correct 13 ms 65624 KB Output is correct
6 Correct 13 ms 65628 KB Output is correct
7 Correct 13 ms 65628 KB Output is correct
8 Correct 14 ms 65884 KB Output is correct
9 Correct 13 ms 65628 KB Output is correct
10 Correct 15 ms 65624 KB Output is correct
11 Correct 13 ms 65628 KB Output is correct
12 Correct 13 ms 65628 KB Output is correct
13 Correct 14 ms 65704 KB Output is correct
14 Correct 13 ms 65624 KB Output is correct
15 Correct 12 ms 65624 KB Output is correct
16 Correct 15 ms 65744 KB Output is correct
17 Correct 14 ms 65628 KB Output is correct
18 Correct 15 ms 65884 KB Output is correct
19 Correct 13 ms 65624 KB Output is correct
20 Correct 16 ms 65628 KB Output is correct
21 Correct 14 ms 65660 KB Output is correct
22 Correct 14 ms 65644 KB Output is correct
23 Correct 13 ms 65628 KB Output is correct
24 Correct 14 ms 65628 KB Output is correct
25 Correct 15 ms 65688 KB Output is correct
26 Correct 14 ms 65628 KB Output is correct
27 Correct 14 ms 65624 KB Output is correct
28 Correct 15 ms 65884 KB Output is correct
29 Correct 17 ms 65880 KB Output is correct
30 Correct 17 ms 65624 KB Output is correct
31 Correct 16 ms 65884 KB Output is correct
32 Correct 16 ms 65604 KB Output is correct
33 Correct 15 ms 65628 KB Output is correct
34 Correct 19 ms 65668 KB Output is correct
35 Correct 20 ms 65840 KB Output is correct
36 Correct 18 ms 65884 KB Output is correct
37 Correct 17 ms 65828 KB Output is correct
38 Correct 72 ms 68232 KB Output is correct
39 Correct 48 ms 81236 KB Output is correct
40 Correct 81 ms 68088 KB Output is correct
41 Correct 85 ms 67668 KB Output is correct
42 Correct 71 ms 68068 KB Output is correct
43 Correct 40 ms 67152 KB Output is correct
44 Correct 60 ms 66640 KB Output is correct
45 Correct 53 ms 71952 KB Output is correct
46 Correct 55 ms 71764 KB Output is correct
47 Correct 48 ms 76368 KB Output is correct
48 Correct 54 ms 76568 KB Output is correct
49 Correct 50 ms 72020 KB Output is correct
50 Correct 51 ms 72020 KB Output is correct
51 Correct 44 ms 72532 KB Output is correct
52 Correct 44 ms 72648 KB Output is correct
53 Correct 45 ms 66908 KB Output is correct
54 Correct 59 ms 71868 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 65628 KB Output is correct
2 Correct 13 ms 65676 KB Output is correct
3 Correct 12 ms 65628 KB Output is correct
4 Correct 13 ms 65880 KB Output is correct
5 Correct 39 ms 65628 KB Output is correct
6 Correct 13 ms 65628 KB Output is correct
7 Correct 15 ms 65628 KB Output is correct
8 Correct 13 ms 65656 KB Output is correct
9 Correct 13 ms 65628 KB Output is correct
10 Correct 13 ms 65696 KB Output is correct
11 Correct 15 ms 65628 KB Output is correct
12 Correct 18 ms 65864 KB Output is correct
13 Correct 105 ms 66344 KB Output is correct
14 Correct 123 ms 66456 KB Output is correct
15 Correct 125 ms 66376 KB Output is correct
16 Correct 162 ms 87840 KB Output is correct
17 Correct 1196 ms 178168 KB Output is correct
18 Correct 2803 ms 287976 KB Output is correct
19 Correct 337 ms 104448 KB Output is correct
20 Correct 334 ms 104332 KB Output is correct
21 Correct 341 ms 104748 KB Output is correct
22 Correct 1105 ms 172628 KB Output is correct
23 Correct 688 ms 172080 KB Output is correct
24 Correct 703 ms 171280 KB Output is correct
25 Correct 640 ms 172048 KB Output is correct
26 Correct 673 ms 171880 KB Output is correct
27 Correct 1746 ms 216880 KB Output is correct
28 Correct 1731 ms 222064 KB Output is correct
29 Correct 1736 ms 214692 KB Output is correct
30 Correct 784 ms 148152 KB Output is correct
31 Correct 756 ms 149172 KB Output is correct
32 Correct 845 ms 167372 KB Output is correct
33 Correct 802 ms 176052 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 65624 KB Output is correct
2 Correct 12 ms 65628 KB Output is correct
3 Correct 12 ms 65624 KB Output is correct
4 Correct 28 ms 65628 KB Output is correct
5 Correct 51 ms 66380 KB Output is correct
6 Correct 13 ms 65740 KB Output is correct
7 Correct 17 ms 65628 KB Output is correct
8 Correct 18 ms 65908 KB Output is correct
9 Correct 64 ms 68180 KB Output is correct
10 Correct 49 ms 81264 KB Output is correct
11 Correct 44 ms 66044 KB Output is correct
12 Correct 122 ms 66644 KB Output is correct
13 Correct 354 ms 148104 KB Output is correct
14 Correct 364 ms 148916 KB Output is correct
15 Correct 927 ms 169812 KB Output is correct
16 Correct 2707 ms 299252 KB Output is correct
17 Correct 456 ms 192196 KB Output is correct
18 Correct 698 ms 214508 KB Output is correct
19 Correct 440 ms 186400 KB Output is correct
20 Correct 449 ms 186652 KB Output is correct
21 Correct 503 ms 200464 KB Output is correct
22 Correct 297 ms 145696 KB Output is correct
23 Correct 12 ms 65624 KB Output is correct
24 Correct 12 ms 65628 KB Output is correct
25 Correct 14 ms 65628 KB Output is correct
26 Correct 14 ms 65664 KB Output is correct
27 Correct 13 ms 65624 KB Output is correct
28 Correct 13 ms 65628 KB Output is correct
29 Correct 13 ms 65628 KB Output is correct
30 Correct 14 ms 65884 KB Output is correct
31 Correct 13 ms 65628 KB Output is correct
32 Correct 15 ms 65624 KB Output is correct
33 Correct 13 ms 65628 KB Output is correct
34 Correct 13 ms 65628 KB Output is correct
35 Correct 14 ms 65704 KB Output is correct
36 Correct 13 ms 65624 KB Output is correct
37 Correct 12 ms 65624 KB Output is correct
38 Correct 15 ms 65744 KB Output is correct
39 Correct 14 ms 65628 KB Output is correct
40 Correct 15 ms 65884 KB Output is correct
41 Correct 13 ms 65624 KB Output is correct
42 Correct 16 ms 65628 KB Output is correct
43 Correct 14 ms 65660 KB Output is correct
44 Correct 14 ms 65644 KB Output is correct
45 Correct 13 ms 65628 KB Output is correct
46 Correct 14 ms 65628 KB Output is correct
47 Correct 15 ms 65688 KB Output is correct
48 Correct 14 ms 65628 KB Output is correct
49 Correct 14 ms 65624 KB Output is correct
50 Correct 15 ms 65884 KB Output is correct
51 Correct 17 ms 65880 KB Output is correct
52 Correct 17 ms 65624 KB Output is correct
53 Correct 16 ms 65884 KB Output is correct
54 Correct 16 ms 65604 KB Output is correct
55 Correct 15 ms 65628 KB Output is correct
56 Correct 19 ms 65668 KB Output is correct
57 Correct 20 ms 65840 KB Output is correct
58 Correct 18 ms 65884 KB Output is correct
59 Correct 17 ms 65828 KB Output is correct
60 Correct 72 ms 68232 KB Output is correct
61 Correct 48 ms 81236 KB Output is correct
62 Correct 81 ms 68088 KB Output is correct
63 Correct 85 ms 67668 KB Output is correct
64 Correct 71 ms 68068 KB Output is correct
65 Correct 40 ms 67152 KB Output is correct
66 Correct 60 ms 66640 KB Output is correct
67 Correct 53 ms 71952 KB Output is correct
68 Correct 55 ms 71764 KB Output is correct
69 Correct 48 ms 76368 KB Output is correct
70 Correct 54 ms 76568 KB Output is correct
71 Correct 50 ms 72020 KB Output is correct
72 Correct 51 ms 72020 KB Output is correct
73 Correct 44 ms 72532 KB Output is correct
74 Correct 44 ms 72648 KB Output is correct
75 Correct 45 ms 66908 KB Output is correct
76 Correct 59 ms 71868 KB Output is correct
77 Correct 12 ms 65628 KB Output is correct
78 Correct 13 ms 65676 KB Output is correct
79 Correct 12 ms 65628 KB Output is correct
80 Correct 13 ms 65880 KB Output is correct
81 Correct 39 ms 65628 KB Output is correct
82 Correct 13 ms 65628 KB Output is correct
83 Correct 15 ms 65628 KB Output is correct
84 Correct 13 ms 65656 KB Output is correct
85 Correct 13 ms 65628 KB Output is correct
86 Correct 13 ms 65696 KB Output is correct
87 Correct 15 ms 65628 KB Output is correct
88 Correct 18 ms 65864 KB Output is correct
89 Correct 105 ms 66344 KB Output is correct
90 Correct 123 ms 66456 KB Output is correct
91 Correct 125 ms 66376 KB Output is correct
92 Correct 162 ms 87840 KB Output is correct
93 Correct 1196 ms 178168 KB Output is correct
94 Correct 2803 ms 287976 KB Output is correct
95 Correct 337 ms 104448 KB Output is correct
96 Correct 334 ms 104332 KB Output is correct
97 Correct 341 ms 104748 KB Output is correct
98 Correct 1105 ms 172628 KB Output is correct
99 Correct 688 ms 172080 KB Output is correct
100 Correct 703 ms 171280 KB Output is correct
101 Correct 640 ms 172048 KB Output is correct
102 Correct 673 ms 171880 KB Output is correct
103 Correct 1746 ms 216880 KB Output is correct
104 Correct 1731 ms 222064 KB Output is correct
105 Correct 1736 ms 214692 KB Output is correct
106 Correct 784 ms 148152 KB Output is correct
107 Correct 756 ms 149172 KB Output is correct
108 Correct 845 ms 167372 KB Output is correct
109 Correct 802 ms 176052 KB Output is correct
110 Correct 118 ms 66748 KB Output is correct
111 Correct 66 ms 66132 KB Output is correct
112 Correct 1269 ms 193772 KB Output is correct
113 Correct 380 ms 112980 KB Output is correct
114 Correct 963 ms 187408 KB Output is correct
115 Correct 64 ms 76376 KB Output is correct
116 Correct 698 ms 139412 KB Output is correct
117 Correct 3949 ms 340920 KB Output is correct
118 Correct 61 ms 72784 KB Output is correct
119 Correct 75 ms 72828 KB Output is correct
120 Correct 44 ms 72392 KB Output is correct
121 Correct 977 ms 148400 KB Output is correct
122 Correct 892 ms 148552 KB Output is correct
123 Correct 465 ms 121900 KB Output is correct
124 Correct 434 ms 121764 KB Output is correct
125 Correct 489 ms 127560 KB Output is correct
126 Correct 2904 ms 305752 KB Output is correct
127 Correct 1110 ms 250212 KB Output is correct
128 Correct 985 ms 247672 KB Output is correct
129 Correct 846 ms 248480 KB Output is correct
130 Correct 901 ms 247856 KB Output is correct