QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#86552#5717. 密码锁xiaoyaowudi95 2059ms21624kbC++146.6kb2023-03-10 07:43:092023-03-10 07:43:13

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-03-10 07:43:13]
  • 评测
  • 测评结果:95
  • 用时:2059ms
  • 内存:21624kb
  • [2023-03-10 07:43:09]
  • 提交

answer

#include <algorithm>
#include <iostream>
#include <array>
#include <tuple>
#include <vector>
constexpr int N(5e4+10),K(4),inf(1e9),M(4e5+10),A(6e4);
int a[N][K],n,k,bb[N][K],cc[N][K];
namespace subtask1
{
	int solve()
	{
		int mx(0),mn(inf);
		for(int i(1);i<=n;++i) mx=std::max(mx,a[i][0]),mn=std::min(mn,a[i][0]);
		return mx-mn;
	}
}
// namespace T
// {
// 	struct _z
// 	{
// 		int mx,tg;
// 		bool clr;
// 	}z[(A+10)<<2];
// 	void clear(int u)
// 	{
// 		z[u].mx=0;z[u].tg=0;
// 		z[u].clr=true;
// 	}
// 	void add(int u,int v)
// 	{
// 		z[u].mx+=v;z[u].tg+=v;
// 	}
// 	void pd(int u)
// 	{
// 		if(z[u].clr)
// 		{
// 			clear(u<<1);clear(u<<1|1);z[u].clr=false;
// 		}
// 		if(z[u].tg)
// 		{
// 			add(u<<1,z[u].tg);add(u<<1|1,z[u].tg);z[u].tg=0;
// 		}
// 	}
// 	void pu(int u)
// 	{
// 		z[u].mx=std::max(z[u<<1].mx,z[u<<1|1].mx);
// 	}
// 	void add(int u,int cl,int cr,int ql,int qr,int v)
// 	{
// 		if(cl>=ql && cr<=qr){add(u,v);return;}if(cl!=cr) pd(u);int mid((cl+cr)>>1);
// 		if(ql<=mid) add(u<<1,cl,mid,ql,qr,v);if(qr>mid) add(u<<1|1,mid+1,cr,ql,qr,v);pu(u);
// 	}
// }
namespace T
{
	struct _z
	{
		int tg,mx;
	}z[(A+10)<<2];
	int m;
	void build(int k)
	{
		m=1;
		while(m<(k+2)) m<<=1;
		for(int i(1);i<(m<<1);++i) z[i].tg=z[i].mx=0;
	}
	int mx(int a,int b){return a>b?a:b;}
	void mdf(int l,int r,int v)
	{
		for(l+=m-1,r+=m+1;l^r^1;l>>=1,r>>=1)
		{
			if(l&1^1) z[l^1].tg+=v,z[l^1].mx+=v;
			if(r&1)   z[r^1].tg+=v,z[r^1].mx+=v;
			z[l>>1].mx=mx(z[l].mx,z[l^1].mx)+z[l>>1].tg;
			z[r>>1].mx=mx(z[r].mx,z[r^1].mx)+z[r>>1].tg;
		}
		while(l>1) z[l>>1].mx=mx(z[l].mx,z[l^1].mx)+z[l>>1].tg,(l>>=1);
	}
}
namespace subtask2
{
	int vsum(0);
	struct rect
	{
		int xl,xm,yl,ym,val;
	};
	int calc(rect *rs,int n,int m)
	{
		vsum+=n;
		struct lne
		{
			int x,yl,yr,val;
			bool operator<(const lne & b) const {return x<b.x;}
		};
		static std::vector<std::tuple<int,int,int>> ls[N*K*2];
		for(int i(1);i<=m+1;++i) ls[i].clear();
		// static lne ls[M*2];int lc(0);
		for(int i(1);i<=n;++i)
		{
			// ls[++lc]={rs[i].xl,rs[i].yl,rs[i].ym,rs[i].val};
			// ls[++lc]={rs[i].xm+1,rs[i].yl,rs[i].ym,-rs[i].val};
			ls[rs[i].xl].emplace_back(rs[i].yl,rs[i].ym,rs[i].val);
			ls[rs[i].xm+1].emplace_back(rs[i].yl,rs[i].ym,-rs[i].val);
		}
		// std::sort(ls+1,ls+lc+1);
		// T::clear(1);
		T::build(m);
		int ans(0);
		// for(int i(1),j;i<=lc;i=j)
		// {
		// 	for(j=i;j<=lc && ls[j].x==ls[i].x;++j)
		// 	{
		// 		// T::add(1,1,A,ls[j].yl,ls[j].yr,ls[j].val);
		// 		T::mdf(ls[j].yl,ls[j].yr,ls[j].val);
		// 	}
		// 	ans=std::max(ans,T::z[1].mx);
		// }
		for(int i(1);i<=m;++i)
		{
			for(auto [l,r,v]:ls[i])
			{
				T::mdf(l,r,v);
			}
			ans=std::max(ans,T::z[1].mx);
		}
		return ans;
		// return 0;
	}
	int solve(int col_mx,int col_mn,int row_mx,int row_mn,int bg)
	{
		int l(0),r(bg-1),mid,ans(inf);
		for(int i(0);i<k;++i) l=std::max(l,std::abs(a[col_mx][i]-a[col_mn][i]));
		auto check=[&](int lim)->bool
		{
			static rect vt[M];int vc(0);
			static std::pair<int,int> k3[M];int k3c(0);
			static int uv[M];int uc(0);
			static int mm[A],qid,vis[A];
			++qid;
			for(int i(1);i<=n;++i) for(int t(0);t<4;++t) vis[a[i][t]]=qid,vis[a[i][t]+lim]=qid;
			for(int i(1);i<A;++i) if(vis[i]==qid) mm[i]=++uc;
			// std::sort(uv+1,uv+uc+1);uc=std::unique(uv+1,uv+uc+1)-uv-1;
			auto idx=[&](int k)->int{return mm[k];};
			for(int i(1);i<=n;++i) for(int t(0);t<k;++t) bb[i][t]=idx(a[i][t]),cc[i][t]=idx(a[i][t]+lim);
			for(int i(1);i<=n;++i)
			{
				static rect av[10];int cnt(0);
				for(int j(0);j<k;++j)
				{
					if(a[col_mx][row_mx]-a[i][row_mx]<=lim && a[i][row_mn]-a[col_mn][row_mn]<=lim)
					{
						static std::pair<int,int> rs[2];int c(0);
						for(int t(0);t<k;++t) if(t!=row_mx && t!=row_mn)
						{
							rs[c++]={bb[i][t],cc[i][t]};
						}
						for(int j(c);j<2;++j) rs[j]={1,1};
						av[cnt++]=(rect){rs[0].first,rs[0].second,rs[1].first,rs[1].second,0};
					}
					if(i==col_mn || i==col_mx) break;
					std::rotate(a[i],a[i]+1,a[i]+k);
					std::rotate(bb[i],bb[i]+1,bb[i]+k);
					std::rotate(cc[i],cc[i]+1,cc[i]+k);
				}
				// std::cerr<<cnt<<std::endl;
				if(!cnt) return false;
				if(k==3)
				{
					std::sort(av,av+cnt,[](auto a,auto b){return a.xl<b.xl;});
					for(int j(0),lm(-inf);j<cnt;++j)
					{
						if(lm<av[j].xm)
						{
							k3[++k3c]={std::max(lm+1,av[j].xl),1};
							k3[++k3c]={av[j].xm+1,-1};lm=av[j].xm;
						}
					}
				}
				else if(k==4)
				{
					for(int j(1);j<(1<<cnt);++j)
					{
						int xl(0),xm(inf),yl(0),ym(inf),val((__builtin_popcount(j)&1)?1:-1);
						for(int t(0);t<cnt;++t) if((j>>t)&1) xl=std::max(xl,av[t].xl),xm=std::min(xm,av[t].xm),yl=std::max(yl,av[t].yl),ym=std::min(ym,av[t].ym);
						if(xl<=xm && yl<=ym)
						{
							vt[++vc]=(rect){xl,xm,yl,ym,val};
							// std::cerr<<lim<<" "<<i<<" "<<xl<<" "<<xm<<" "<<yl<<" "<<ym<<" "<<val<<std::endl;
						}
					}
				}
			}
			if(k==2) return true;
			else if(k==3)
			{
				std::sort(k3+1,k3+k3c+1);
				int cur(0);
				// for(int i(1);i<=k3c;++i)
				// {
				// 	std::cerr<<k3[i].first<<","<<k3[i].second<<" ";
				// }
				// std::cerr<<std::endl;
				for(int i(1);i<=k3c;++i)
				{
					cur+=k3[i].second;
					if(cur==n) return true;
				}
				return false;
			}
			else return calc(vt,vc,uc)==n;
			// else return true;
		};
		while(l<=r)
		{
			mid=(l+r)>>1;
			if(check(mid)){ans=mid;r=mid-1;}
			else{l=mid+1;}
		}
		return ans;
	}
	int solve()
	{
		int mx(0),mn(inf);
		std::pair<int,int> mp{0,0},np{0,0};
		for(int i(1);i<=n;++i)
		{
			for(int j(0);j<k;++j)
			{
				if(a[i][j]>mx){mx=a[i][j];mp={i,j};}
				if(a[i][j]<mn){mn=a[i][j];np={i,j};}
			}
		}
		if(mx==mn) return 0;
		int ans(mx-mn);
		// std::cerr<<mx<<" "<<mn<<" "<<mp.first<<" "<<mp.second<<" "<<np.first<<" "<<np.second<<std::endl;
		if(mp.first==np.first)
		{
			ans=std::min(solve(mp.first,mp.first,mp.second,np.second,ans),ans);
		}
		else
		{
			for(int i(0);i<k;++i)
			{
				if((np.second-i+k)%k!=mp.second) ans=std::min(ans,solve(mp.first,np.first,mp.second,(np.second-i+k)%k,ans));
				std::rotate(a[np.first],a[np.first]+1,a[np.first]+k);
			}
		}
		return ans;
	}
}
int main()
{
	std::ios::sync_with_stdio(false);std::cin.tie(nullptr);
	int T;std::cin>>T>>k;int sumn(0);
	while(T--)
	{
		std::cin>>n;sumn+=n;
		for(int i(0);i<k;++i)
		{
			for(int j(1);j<=n;++j) std::cin>>a[j][i];
		}
		if(k==1){std::cout<<subtask1::solve()<<"\n";}
		else{std::cout<<subtask2::solve()<<"\n";}
	}
	// std::cerr<<sumn<<std::endl;
	// std::cerr<<subtask2::vsum<<std::endl;
	return 0;
}

詳細信息

Test #1:

score: 5
Accepted
time: 2ms
memory: 3420kb

input:

5 1
20
20828 22671 20646 13184 13779 12445 15192 14863 14396 19238 16788 20325 16831 8559 13417 8768 13227 8760 12456 12091
20
17138 10757 10189 4459 19805 4791 8043 15409 14758 15901 9004 13481 20599 17218 14056 5078 8021 16969 22031 15690
20
26410 25246 16063 9589 20080 21752 25766 14007 12750 231...

output:

14112
17572
16821
21321
16199

result:

ok 5 number(s): "14112 17572 16821 21321 16199"

Test #2:

score: 5
Accepted
time: 12ms
memory: 4152kb

input:

3 1
50000
15429 14039 16730 23945 7044 17994 15646 15950 7744 7726 19830 8000 7607 19562 22681 17139 19133 13561 14539 21246 8476 20813 21139 18999 18270 11950 19511 14822 24627 20644 10619 7699 8058 9578 8425 12058 22166 12276 21095 22645 8087 24264 21082 16567 18500 15489 14629 16114 19826 22286 1...

output:

18373
18000
18000

result:

ok 3 number(s): "18373 18000 18000"

Test #3:

score: 5
Accepted
time: 2ms
memory: 3836kb

input:

5 2
20
3646 6903 10939 9491 14584 16498 7415 10353 8781 10454 703 4651 11986 3700 2186 21659 18792 6774 15283 9422
22629 3204 24229 11810 15271 20496 13170 19867 6105 13572 6657 11440 22722 22564 10168 2797 5798 11753 18320 12720
20
18619 25811 14645 26890 3897 11154 16664 20111 15847 16651 8537 116...

output:

17572
18784
14814
14107
15187

result:

ok 5 number(s): "17572 18784 14814 14107 15187"

Test #4:

score: 5
Accepted
time: 69ms
memory: 3884kb

input:

186 2
5
10809 20957 1456 13581 19134
19871 12718 14451 14783 23041
7
24553 4790 18932 21045 14061 6438 17183
9155 15756 16480 17055 13768 11550 15400
4
12340 23115 28018 8781
16634 10828 1457 21446
7
9619 7632 22338 17091 11090 3368 4366
17684 14282 25007 9194 3144 9944 15465
3
3024 25036 17327
2034...

output:

17678
13003
11384
19194
20499
16143
15079
11508
11891
22699
12676
11250
16873
3238
9264
8040
18134
10772
27251
15001
14812
6575
5499
18396
18795
10752
17672
13273
13915
15178
8303
15337
11707
18835
16270
10944
15953
22359
4914
17434
19001
3224
14155
17053
8670
17906
18767
3696
10036
10580
23062
7636...

result:

ok 186 numbers

Test #5:

score: 5
Accepted
time: 500ms
memory: 4004kb

input:

1357 2
6
1679 1896 8067 24584 3225 2239
14688 13434 4956 688 2751 5016
5
18325 12446 17937 6311 21564
24096 6172 17497 25829 12016
3
9440 752 22972
11570 26214 5969
3
13475 23941 17551
9287 14467 15412
2
20079 827
5314 5994
3
24501 13180 9614
25780 17665 18145
4
16980 22134 5840 14181
16144 7553 773...

output:

21359
13383
14644
10466
14085
14887
14396
19769
12727
14894
9957
19961
16696
14903
12494
14811
13441
15241
5475
15280
10050
15477
10792
15489
14676
21437
19598
12192
15812
10749
24133
15641
24351
20130
8512
11012
19409
7014
18531
9567
17379
4718
13822
15877
11260
17467
12318
12804
19625
4182
20704
1...

result:

ok 1357 numbers

Test #6:

score: 5
Accepted
time: 86ms
memory: 6264kb

input:

3 2
50000
7513 17243 9697 14636 12922 14859 12193 5056 13705 14408 13089 11378 14342 14499 15298 9625 22287 6924 7449 7005 13845 14641 18588 7768 17917 8750 15618 18464 13925 8818 17391 13200 2575 11253 4899 12707 7147 18547 8379 17524 11779 19107 23448 10551 9856 5503 8494 1692 14681 13130 17456 15...

output:

18000
18000
21622

result:

ok 3 number(s): "18000 18000 21622"

Test #7:

score: 5
Accepted
time: 5ms
memory: 3888kb

input:

5 3
10
16030 9693 27756 24507 23211 17464 8887 7416 13135 4895
17169 11454 10400 13490 11738 22678 15050 29009 12184 12183
6893 16992 11689 16565 26352 8380 18580 20848 9410 21743
10
1128 13324 10854 697 15189 7294 1871 12509 18641 18737
8263 13121 15061 18066 16059 11121 24606 17909 1413 9992
12404...

output:

16826
16195
14672
17434
14651

result:

ok 5 number(s): "16826 16195 14672 17434 14651"

Test #8:

score: 5
Accepted
time: 11ms
memory: 3856kb

input:

10 3
50
12127 17615 4504 20695 16125 18833 13652 5613 8019 15730 16385 3568 14282 14276 13925 16974 8261 24045 9779 1487 3759 15923 7152 21549 26107 14901 14057 5048 12826 6651 12380 18877 17171 4811 18423 22750 12101 8463 7906 20052 9943 4320 11309 23876 6387 7655 3242 14459 14963 6580
20320 8545 2...

output:

18252
16219
18615
15968
20398
17291
22169
17075
17681
17390

result:

ok 10 numbers

Test #9:

score: 5
Accepted
time: 258ms
memory: 4104kb

input:

492 3
6
8092 24146 5245 25301 8773 26713
20068 26047 4375 21461 28935 4037
28742 5614 21217 11156 23813 14955
4
26596 4665 12954 28516
2539 28719 26192 23894
9531 18883 18267 9946
4
15563 2548 22395 29261
1483 598 24912 12610
17817 9629 17119 7397
5
11066 7676 29263 9309 5342
18273 24030 25203 5102 ...

output:

19776
19188
21797
18197
16488
9621
18985
14281
13947
14275
11892
9245
17832
17173
17726
9662
18620
13692
17887
16482
23818
21403
13634
12965
6193
18261
13831
13028
12865
19479
17691
16458
13698
18656
19260
6233
12146
11289
11588
13898
18827
10520
21260
13972
11976
11540
18082
16415
18846
24749
9902
...

result:

ok 492 numbers

Test #10:

score: 5
Accepted
time: 1521ms
memory: 4352kb

input:

2823 3
7
11008 15379 3474 23505 21289 13545 21951
14190 11309 11018 12827 20349 17613 20448
14242 15097 16392 7823 18077 27988 12213
4
10305 19014 15560 26972
21128 9755 5367 23887
17563 15511 13210 12065
5
7016 12729 24261 5979 12169
21967 10993 25792 11527 11476
21349 2172 20428 22930 23721
6
1562...

output:

14603
13762
18256
16513
15764
21273
11977
12505
8396
21677
12517
21399
12827
15856
14628
12291
14834
18210
19601
13710
10595
10094
17897
16185
18524
13388
10652
12097
8966
11074
9961
9831
15566
19751
18182
15649
12751
15690
12487
15892
16475
15285
5549
11479
13063
8339
9186
13834
14067
12428
23249
1...

result:

ok 2823 numbers

Test #11:

score: 5
Accepted
time: 289ms
memory: 6244kb

input:

4 3
30000
8497 11286 8353 2876 13129 10774 10578 13288 16631 14892 4744 10355 11083 16465 12953 9099 9278 12561 12862 13392 1500 17077 11412 4467 14626 14772 8321 8327 3999 11277 13029 4212 1734 13474 13656 8398 762 10438 14080 15473 3866 7574 10692 16389 4413 9044 18604 1591 10649 14576 10155 10361...

output:

10103
10118
10196
10178

result:

ok 4 number(s): "10103 10118 10196 10178"

Test #12:

score: 5
Accepted
time: 739ms
memory: 8284kb

input:

3 3
50000
19199 27507 19780 17075 20200 20902 22589 12623 21750 21336 4538 24298 18509 16201 16796 6650 19468 19507 25451 27321 18009 23942 24617 24422 26676 8908 4600 11408 20067 23198 23582 16086 21592 19845 18972 17985 11853 25099 28717 27759 10596 23082 27902 19323 16693 8408 26792 20131 22735 2...

output:

10040
15453
19023

result:

ok 3 number(s): "10040 15453 19023"

Test #13:

score: 5
Accepted
time: 13ms
memory: 13284kb

input:

5 4
10
12871 9817 14695 11872 16291 27028 1392 12572 10409 3017
16310 28902 7458 24546 13098 2633 26901 14337 17441 63
26236 2514 24674 23157 9327 13531 25862 26834 24256 21476
22242 24748 23021 17878 26324 12312 3909 28308 3462 20168
10
20846 29205 14900 19250 722 6157 15661 8441 17182 11169
3390 1...

output:

24685
22656
22046
23738
22355

result:

ok 5 number(s): "24685 22656 22046 23738 22355"

Test #14:

score: 5
Accepted
time: 22ms
memory: 13352kb

input:

10 4
50
19704 7323 15828 22182 10893 7859 16948 16603 28637 8205 12361 2532 5845 23202 10647 14169 15901 24468 1029 25019 26328 18995 14057 6145 13869 15274 5361 22018 4967 1745 16752 19883 926 78 6747 7515 8391 21114 28634 18985 27576 5184 3502 25152 21983 2702 11587 9661 9052 23658
5746 9465 16337...

output:

26043
27185
27397
26352
28517
26578
25856
25676
28104
25894

result:

ok 10 numbers

Test #15:

score: 5
Accepted
time: 214ms
memory: 13532kb

input:

296 4
5
14984 9981 9017 21474 22589
15490 4551 17062 14214 18005
5994 11883 5919 13543 16909
18835 23523 17149 11464 14979
6
14169 24435 27207 2521 14770 2155
8254 9241 12877 22826 18706 14972
19413 12325 7660 19399 13082 17109
21888 14786 17154 13755 1801 9630
7
12587 18433 18081 13142 19835 14986 ...

output:

12511
10524
18268
18094
17939
12851
11657
17111
14244
19726
17196
16208
18788
15137
18399
10145
14959
13270
14484
20078
14814
18087
16894
11828
23192
24887
14794
15738
21539
22505
20498
11968
17556
21716
9821
21038
20046
13142
19941
18880
15711
10544
19569
13011
12045
18762
11510
13108
20176
16102
1...

result:

ok 296 numbers

Test #16:

score: 5
Accepted
time: 411ms
memory: 13756kb

input:

556 4
6
24538 1561 15955 25462 13820 18425
23525 16200 7272 8057 14559 13522
4043 13481 11449 26789 19442 22612
19442 17815 15054 14372 24215 15908
7
4992 21533 18540 20730 21070 25918 14971
18953 15648 18255 12969 20983 12375 20955
4379 23010 25490 28045 16038 13733 27907
7885 27116 20057 29239 136...

output:

15340
23053
13559
23172
14989
14339
12399
12797
17439
19464
17954
16936
16876
23513
15667
12337
19783
13724
18516
21357
18068
22247
12341
23511
14801
10506
11572
9374
17598
13758
13755
17614
20779
15389
17645
14177
15511
23190
20611
15695
21937
22119
13534
20474
18298
20579
14677
14012
19496
20429
1...

result:

ok 556 numbers

Test #17:

score: 5
Accepted
time: 929ms
memory: 17212kb

input:

910 4
5
18495 4213 7072 24451 5053
24983 1518 19953 25740 1087
4368 10700 8715 18200 28641
14575 2496 27461 27488 13358
4
9653 12755 22556 17654
21198 18496 17358 19398
27223 11305 27527 21344
22554 19509 8064 23976
7
1138 20361 16799 21891 18013 21953 4783
12601 3538 13276 22157 13538 10272 24627
2...

output:

21955
14468
16634
18296
16350
11548
20506
13501
22262
19344
18475
20066
17636
15124
24275
19747
21989
20782
18640
14872
11375
14879
21998
18443
13717
25115
12706
18136
23493
13745
16521
12208
16001
18263
18400
23617
10163
14338
15277
23845
14012
17613
19900
8042
0
11551
13270
15543
21395
17116
17366...

result:

ok 910 numbers

Test #18:

score: 5
Accepted
time: 1631ms
memory: 19528kb

input:

1826 4
5
12038 3573 20463 6119 19486
9769 26360 9873 3880 27288
14634 18318 2181 14462 7044
18465 4615 19511 28217 543
5
29712 7598 12660 5404 13631
8149 15497 14057 12916 16856
23561 10256 5404 6465 13656
6258 12169 17157 15896 14018
6
10545 25243 9487 14739 13377 3270
7836 5934 29067 27149 19583 1...

output:

11898
14215
22984
21851
15408
19410
7192
19889
17373
22863
19336
16456
16888
13820
16097
13914
8616
10866
13444
14903
11845
17773
24730
17164
23083
18271
15779
25674
19116
24944
22504
9813
19429
14764
16853
15871
23291
16732
19851
19080
17257
13462
12114
15378
20429
18445
18873
19736
15068
13227
265...

result:

ok 1826 numbers

Test #19:

score: 5
Accepted
time: 2059ms
memory: 21624kb

input:

1834 4
5
14031 15017 11718 8584 24580
2938 13523 5087 3420 27335
16189 5418 9070 14669 21628
22686 16121 15677 21857 26168
4
13628 4601 13896 2382
5508 5343 25068 22533
17027 14789 2864 19773
26676 3034 11148 26438
5
20602 13848 6353 13350 23468
26366 10523 24372 8484 24138
4007 21029 5227 14962 231...

output:

18751
17932
17785
20577
14948
18357
13497
10772
14615
10585
12000
15998
16288
15554
16718
18448
21625
12774
14554
16940
17792
13385
15268
18042
20204
13673
18532
17792
20182
12990
20140
18575
18426
19062
13277
15160
17362
23041
14704
13052
19214
9358
10732
16774
14760
19422
10394
15437
16916
20923
2...

result:

ok 1834 numbers

Test #20:

score: 0
Time Limit Exceeded

input:

3 4
10000
27024 14111 22404 5025 23580 12815 13934 2337 12175 11404 6514 12919 22433 27537 25780 7967 6642 17225 21192 14830 1691 1887 11039 7793 3178 8346 22904 16381 5296 29290 20246 12878 21843 11597 11199 7069 14778 10902 24331 15641 21285 16597 16428 20494 26998 7139 14721 10644 25003 13823 268...

output:


result: