QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#935751#10218. Travel on the GridFlammable Dumpster (Lin Wu, Pengrui Zhu, Qingyang Li)#AC ✓67ms35088kbC++142.3kb2025-03-15 16:10:012025-03-15 16:10:03

Judging History

This is the latest submission verdict.

  • [2025-03-15 16:10:03]
  • Judged
  • Verdict: AC
  • Time: 67ms
  • Memory: 35088kb
  • [2025-03-15 16:10:01]
  • Submitted

answer

#include<iostream>
#include<vector>
#include<queue>
using namespace std;
const int dx[8]={0,0,1,-1,1,1,-1,-1};
const int dy[8]={1,-1,0,0,1,-1,1,-1};
int T,n,m,X,Y,a[1010][1010],f[1010][1010];
char s[1010][1010];
long long F[200010];
vector<pair<int,int> > e[200010];
inline int ID(int x,int y,bool z=0)
{
	return (x-1)*m+y+z*n*m;
}
inline void Add(int x,int y,int z)
{
	e[x].push_back({y,z});
}
struct point
{
	int id;
	long long len;
};
inline bool operator <(const point &a,const point &b)
{
	return a.len>b.len;
}
inline point make(int id,long long len)
{
	point ret;
	ret.id=id,ret.len=len;
	return ret;
}
inline void dijkstra(int S)
{
	static bool mark[200010];
	for(int i=1;i<=(n*m<<1);mark[i++]=0);
	priority_queue<point> q;
	F[S]=0,q.push(make(S,0));
	while(!q.empty())
	{
		int now=q.top().id;
		q.pop();
		if(mark[now])
		{
			continue;
		}
		mark[now]=1;
		for(int i=0;i<e[now].size();i++)
		{
			int t=e[now][i].first;
			int v=e[now][i].second;
			if(F[t]>F[now]+v)
			{
				F[t]=F[now]+v;
				q.push(make(t,F[t]));
			}
		}
	}
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>T;
	while(T--)
	{
		cin>>n>>m>>X>>Y;
		for(int i=1;i<=n;i++)
		{
			cin>>s[i]+1;
		}
		for(int i=1;i<=n;i++)
		{
			for(int j=1;j<=m;j++)
			{
				cin>>a[i][j];
				if(s[i][j]=='#')
				{
					f[i][j]=ID(i,j);
					continue;
				}
				f[i][j]=0;
				for(int k=0;k<4;k++)
				{
					int x=i+dx[k];
					int y=j+dy[k];
					if(!x||!y||x>n||y>m)
					{
						continue;
					}
					if(s[x][y]=='#')
					{
						f[i][j]=ID(x,y);
						break;
					}
				}
			}
		}
		for(int i=1;i<=(n*m<<1);i++)
		{
			e[i].clear(),F[i]=1e18;
		}
		for(int i=1;i<=n;i++)
		{
			for(int j=1;j<=m;j++)
			{
				if(s[i][j]=='#')
				{
					Add(ID(i,j),ID(i,j,1),Y);
				}
				for(int k=0;k<8;k++)
				{
					int x=i+dx[k];
					int y=j+dy[k];
					if(!x||!y||x>n||y>m)
					{
						continue;
					}
					if(f[i][j]==f[x][y]||!f[x][y])
					{
						Add(ID(i,j),ID(x,y),0);
						Add(ID(i,j,1),ID(x,y,1),a[i][j]);
						continue;
					}
					if(s[x][y]=='#')
					{
						Add(ID(i,j),ID(x,y),X);
						Add(ID(i,j,1),ID(x,y),0);
					}
				}
			}
		}
		dijkstra(ID(1,1));
		cout<<F[ID(n,m)]<<endl;
	}
	return 0;
}

这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 15140kb

input:

2
3 4 10 5
....
.#..
...#
0 0 0 0
0 1 2 3
0 0 0 0
3 4 10 10
..#.
....
#..#
0 0 1 0
0 0 0 0
1 0 0 0

output:

16
20

result:

ok 2 lines

Test #2:

score: 0
Accepted
time: 0ms
memory: 13832kb

input:

52
3 4 10 5
....
.#..
...#
0 0 0 0
0 1 2 3
0 0 0 0
3 4 10 10
..#.
....
#..#
0 0 1 0
0 0 0 0
1 0 0 0
4 5 198544248 526775139
..#..
....#
#....
..#..
67367395 24943156 107730602 156933416 76759754
128636797 162308782 42828276 129360799 93166305
35103252 4708196 173171289 23966905 152440335
37532488 14...

output:

16
20
198544248
840063466
646209943
1148328432
3399884664
977725654
230546156
437565214
386141060
220522432
589498141
4400031
590115678
521155818
1078264788
107597823
401825267
196688034
908968600
1027255341
135700674
1153873640
37840896
1597763232
3277799855
2838936492
871373788
230898772
503766934...

result:

ok 52 lines

Test #3:

score: 0
Accepted
time: 1ms
memory: 14744kb

input:

100
7 7 2 4
..#..#.
.......
#..#..#
.......
.#..#..
......#
#..#...
2 0 0 3 3 0 0
3 0 3 1 2 0 0
3 0 2 2 3 0 0
3 2 3 3 2 2 2
0 3 1 2 2 1 1
0 1 0 1 1 2 1
2 1 1 1 3 1 0
7 7 9 5
..#..#.
.......
#..#..#
.......
.#..#..
......#
#..#...
3 4 1 6 5 3 1
5 0 3 0 2 6 3
5 2 2 5 6 5 1
6 0 1 2 2 6 5
5 2 0 6 2 1 0
...

output:

8
31
16
24
32
24
22
21
18
36
27
13
25
16
16
4
18
14
16
26
31
7
13
24
24
24
29
14
20
21
4
8
25
39
8
12
29
24
16
25
24
12
8
40
20
24
20
20
36
4
40
8
22
28
26
32
16
4
4
4
20
4
31
4
40
13
31
4
22
16
10
27
8
15
16
7
24
6
12
4
12
14
19
13
28
8
32
12
28
4
8
24
12
24
4
16
11
20
28
19

result:

ok 100 lines

Test #4:

score: 0
Accepted
time: 1ms
memory: 13368kb

input:

66
7 7 4 3
..#..#.
.......
#..#..#
.......
.#..#..
......#
#..#...
2 11 7 12 14 14 0
9 17 15 8 15 10 0
18 16 6 13 0 4 11
0 2 1 16 12 7 13
2 10 16 16 1 15 1
16 2 1 17 19 16 17
6 6 18 4 14 16 9
7 7 15 1
..#..#.
.......
#..#..#
.......
.#..#..
.......
#..#..#
1 6 14 2 15 7 1
8 1 11 16 18 4 4
19 12 6 12...

output:

16
45
32
18
48
31
39
43
18
20
44
12
30
9
63
45
15
18
12
6
22
27
25
18
9
40
24
60
9
24
21
31
46
45
30
16
20
57
12
24
61
44
8
55
22
46
37
23
43
8
15
36
80
60
27
37
40
15
21
12
4
12
24
36
51
20

result:

ok 66 lines

Test #5:

score: 0
Accepted
time: 46ms
memory: 28156kb

input:

1
315 315 913066539 922178011
..#..#..#..#..#..#..#..#...#..#...#..#..#..#..#...#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#...#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#.....

output:

127829315460

result:

ok single line: '127829315460'

Test #6:

score: 0
Accepted
time: 49ms
memory: 31160kb

input:

1
315 315 3779972 441532
..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#...#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#...#..#..#..#..#..#..#..#..#...#..#..#...#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#...#..#..#..#..#..#..#..#...

output:

340824491

result:

ok single line: '340824491'

Test #7:

score: 0
Accepted
time: 13ms
memory: 14520kb

input:

50
2 1000 867140753 902512218
..#..#...#..#..#..#..#..#...#...#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#...#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#...#..#..#...#..#..#..#..#..#..#..#..#..#..#..#..#...#..#..#..#..#..#..#..#..#...#...#...

output:

300030700538
343279158285
338725910336
329409625531
338077027264
336708382770
284772576855
261494389152
337773065960
345260872088
312873542520
322302786720
315363374624
317816379720
299617932810
333750196314
316130022756
330283213722
330357744945
344469795030
332709579920
327235500020
290515898664
2...

result:

ok 50 lines

Test #8:

score: 0
Accepted
time: 15ms
memory: 14880kb

input:

50
2 1000 952721 2288907
..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#...#...#..#..#..#..#..#..#..#..#...#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#...#..#...#..#..#...#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#.....

output:

325830582
653761362
1476786325
577607082
1469724151
1031383880
117506960
1718478322
1592902729
679542714
106925685
1150761551
70382228
1900427850
649054241
516964375
1472118613
286794112
1156607057
788699277
981626811
2419947998
21713420
211869342
991294638
119889440
3978125015
60425281
1406245530
1...

result:

ok 50 lines

Test #9:

score: 0
Accepted
time: 12ms
memory: 19204kb

input:

50
1000 2 936027087 883330548
..
..
#.
..
.#
..
..
#.
..
.#
..
#.
..
.#
..
#.
..
.#
..
#.
..
.#
..
#.
..
.#
..
#.
..
.#
..
#.
..
.#
..
#.
..
.#
..
#.
..
.#
..
#.
..
.#
..
#.
..
.#
..
#.
..
.#
..
#.
..
.#
..
#.
..
.#
..
#.
..
.#
..
#.
..
.#
..
#.
..
.#
..
#.
..
.#
..
#.
..
.#
..
#.
..
.#
..
#.
..
.#
...

output:

458653272630
464551005952
475908155206
404001123066
474167227119
446553132760
433256261136
489221006820
400224404510
434894505024
469965265959
485057380290
472978125063
488414942120
453198982232
474218022670
455803141354
444517703388
444609620980
419702190921
430466968104
431877073173
475167477336
4...

result:

ok 50 lines

Test #10:

score: 0
Accepted
time: 12ms
memory: 19204kb

input:

50
1000 2 1499492 8644324
..
.#
..
#.
..
.#
..
#.
..
.#
..
#.
..
.#
..
#.
..
.#
..
#.
..
.#
..
#.
..
.#
..
#.
..
.#
..
#.
..
.#
..
#.
..
.#
..
#.
..
.#
..
..
#.
..
.#
..
#.
..
..
#.
..
.#
..
#.
..
.#
..
#.
..
.#
..
#.
..
.#
..
#.
..
..
#.
..
..
#.
..
.#
..
#.
..
.#
..
..
#.
..
.#
..
#.
..
.#
..
#.
....

output:

728753112
1751918987
2911186541
104196456
222181520
2295907984
1656013434
972393325
745051577
1634487610
2157502241
1142552495
1191966501
1449674306
754295307
3565272672
606597430
1411040570
579310830
1970445128
1812245997
1139311352
450757370
1624396311
1756881174
1557928288
1403042739
11667142
249...

result:

ok 50 lines

Test #11:

score: 0
Accepted
time: 21ms
memory: 13960kb

input:

111
30 30 939780196 968193722
..#..#..#..#..#..#..#..#..#..#
..............................
#..#..#..#..#..#..#..#..#..#..
.............................#
.#..#...#..#..#..#..#..#..#...
......#.....................#.
#..#.....#..#..#..#..#..#.....
.....#....................#..#
.#.....#..#..#..#..#.....

output:

16916043528
14755880592
15781222384
14221288155
12769363785
14408937255
11044663980
15089332528
15533108964
15585199956
14160000144
16215606468
14225779050
16521227470
10580843340
15970194848
16524162112
17856418806
16872709916
14017450266
14193133824
14412856650
12147342466
15799166784
13908846544
...

result:

ok 111 lines

Test #12:

score: 0
Accepted
time: 25ms
memory: 14724kb

input:

111
30 30 7928040 2794026
..#..#...#..#..#..#..#..#..#..
.......#.....................#
#..#......#..#..#..#..#..#....
.....#..#..................#..
.#.........#..#..#..#..#.....#
....#..#.................#....
#........#..#..#..#..#.....#..
..#..#.................#.....#
.......#..#..#..#..#.....#...

output:

59422786
70108392
12603598
38962636
48443564
33512241
16607724
57105030
39831104
39299382
85753954
13382893
78413256
49472787
18588768
98550367
46315378
38658330
93720073
51815653
38056464
10081512
4451203
25040416
5012532
133432754
93572154
52972554
22267680
19289094
1964942
30163770
11535248
78984...

result:

ok 111 lines

Test #13:

score: 0
Accepted
time: 20ms
memory: 13916kb

input:

1000
10 10 911043657 879007351
..#..#..#.
..........
#..#..#..#
..........
.#..#..#..
.........#
#..#..#...
........#.
.#..#.....
......#..#
916800951 980251879 839377325 926364954 973019984 975565092 936928821 959565945 984573403 981625957
723376998 826190018 893800846 943004262 971099366 994070340...

output:

5466261942
3633147704
3802738620
4741593384
5666780394
5983022634
5343572634
5771143392
5197503282
5547911364
5954424078
3450972456
5731960854
5810784966
4911207055
4752382835
3801284416
4887297680
3807989900
5346780012
5293003206
5783433624
5833062006
5512925802
4089413720
5475996378
4748719465
529...

result:

ok 1000 lines

Test #14:

score: 0
Accepted
time: 20ms
memory: 13312kb

input:

1000
10 10 957843 3271843
..#..#..#.
..........
#..#..#..#
..........
.#..#..#..
.........#
#..#......
.....#..#.
.#........
...#..#..#
493829 3611861 3524053 452955 518463 3918664 3458529 6188213 1573994 3199874
8943813 2161280 2685688 621208 3955454 18153114 199133 8027885 780999 599285
1190696 90...

output:

4789215
14200566
22156429
23118958
45236409
25963350
7612336
15182543
2942976
3788310
15187978
21658733
9050041
7996818
15259697
18163727
1207928
1162578
11443122
12690650
25172009
7741768
20616084
25846805
5596439
4684940
8288715
13377432
29598931
12449760
10330834
6021610
3891516
2772450
12585523
...

result:

ok 1000 lines

Test #15:

score: 0
Accepted
time: 17ms
memory: 13756kb

input:

25000
2 2 971587902 947940235
..
.#
970997714 973862053
794570076 999958379
2 2 964543643 911497018
..
.#
925222807 960065829
879580911 863656478
2 2 998828943 979670963
..
.#
910638880 984282264
970996770 958690133
2 2 844234458 949890950
..
.#
894742686 949177971
936831390 932527324
2 2 974020108 ...

output:

971587902
964543643
998828943
844234458
974020108
956219756
993539643
888270913
986742329
971405233
907612784
836331216
903148063
0
962961188
984448104
858855187
880775426
967138224
994184290
986436297
991797019
997531250
841439106
938187409
792082028
856272388
816484957
967803376
984828020
0
839095...

result:

ok 25000 lines

Test #16:

score: 0
Accepted
time: 18ms
memory: 14536kb

input:

25000
2 2 1705512 3750394
..
.#
18663 220972
4651177 3984485
2 2 1097587 656852
..
..
1614120 1784219
7161392 5979771
2 2 5661703 509628
..
.#
3086665 14427114
2358689 2911793
2 2 1825088 2395282
..
.#
4077595 300182
9084412 360764
2 2 595638 6076770
..
.#
1428116 15037870
1990490 1590112
2 2 136698...

output:

1705512
0
5661703
1825088
595638
1366989
0
1548935
1700705
2486728
393717
1012973
2408117
1955753
916869
840533
15475487
0
2509687
2065391
743626
1000941
2587882
2189683
2928269
367776
616743
5147343
983983
2092751
5085534
13905835
6116641
585835
719521
7464671
664592
2037695
7060669
274575
553548
4...

result:

ok 25000 lines

Test #17:

score: 0
Accepted
time: 49ms
memory: 28488kb

input:

1
315 315 949697175 871365651
..#..#..#..#..#..#..#...#..#..#..#...#...#..#..#..#..#..#..#...#..#...#....#..#..#..#..#...#..#..#..#....#..#..#...#..#..#..#...#..#...#..#..#..#..#..#..#..#..#..#..#..#..#..#..#..#...#..#..#..#..#..#..#..#..#..#..#..#...#..#..#...#..#...#..#..#..#..#..#..#..#..#..#..#....

output:

90221231625

result:

ok single line: '90221231625'

Test #18:

score: 0
Accepted
time: 55ms
memory: 31900kb

input:

1
315 315 269652 2928855
..#...#..#..#..#...#....#..#..#..#...#...#..#..#..#..#..#..#..#..#...#...#..#....#..#..#..#..#..#...#..#..#..#..#..#...#...#..#..#..#..#.....#..#...#..#..#.....#...#..#...#...#...#...#...#..#..#..#..#..#..#..#..#...#..#..#..#..#..#..#..#....#..#..#..#..#...#..#..#..#..#..#.....

output:

23999028

result:

ok single line: '23999028'

Test #19:

score: 0
Accepted
time: 12ms
memory: 17144kb

input:

50
2 1000 693608154 956238209
...#..#..#...#..#...#..#..#...#..#..#..#..#..#..#..#..#...#..#..#...#...#..#..#..#..#..#...#..#..#..#..#..#..#..#...#..#..#..#..#..#..#....#..#...#..#..#..#..#...#...#..#..#...#...#..#...#..#...#...#..#..#..#..#..#..#..#....#..#..#..#..#..#..#..#...#..#...#...#..#..#..#...

output:

251779759902
259096891383
342654101559
360749410750
354406865802
331094246742
349887691434
345026901156
357399514836
324007331340
332893148952
338100062760
337031021312
335005970805
310736857443
339624687792
297721402160
350324907714
336256106043
313342920436
342811061576
268944595055
358672561884
3...

result:

ok 50 lines

Test #20:

score: 0
Accepted
time: 17ms
memory: 13584kb

input:

50
2 1000 3455591 10656274
..#..#..#...#..#...#..#..#..#..#....#..#..#....#...#..#..#..#..#..#...#..#..#..#...#..#..#..#..#..#..#..#...#..#..#..#..#...#..#..#..#..#...#..#..#...#..#..#..#..#..#..#.....#..#..#...#..#..#..#..#..#...#...#...#..#...#..#..#...#.....#...#..#..#..#..#..#..#..#..#..#..#..#....

output:

1244012760
92953636
550309703
787030560
585712090
310159066
418500924
57345480
368227220
1074507383
2541104250
1561144078
13449768
1255650612
1765443724
702433314
1165928521
1111799503
66450417
766001254
509382806
1506788723
64992032
1791935403
690916785
1196292024
1353652530
1980341754
2525122704
5...

result:

ok 50 lines

Test #21:

score: 0
Accepted
time: 13ms
memory: 19176kb

input:

50
1000 2 922578667 999993118
..
.#
..
#.
..
.#
..
#.
..
..
#.
..
..
#.
..
..
#.
..
.#
..
#.
..
..
#.
..
.#
..
#.
..
.#
..
#.
..
.#
..
#.
..
.#
..
#.
..
..
.#
..
#.
..
.#
..
..
#.
..
.#
..
#.
..
.#
..
#.
..
.#
..
#.
..
..
#.
..
.#
..
#.
..
.#
..
..
#.
..
..
#.
..
..
#.
..
.#
..
#.
..
.#
..
#.
..
.#
...

output:

411470085482
435733917482
433634926500
387944740185
359970072192
394500539436
381277770720
435375993417
440729129855
427318277526
438257831130
390109757508
378977348106
410347088124
436269388280
425098404636
394431723972
408054610585
430247924040
439264079670
381388014660
390565103355
416602923440
4...

result:

ok 50 lines

Test #22:

score: 0
Accepted
time: 16ms
memory: 19104kb

input:

50
1000 2 4747386 1633446
..
.#
..
#.
..
.#
..
..
#.
..
.#
..
#.
..
.#
..
#.
..
.#
..
#.
..
.#
..
#.
..
.#
..
#.
..
.#
..
#.
..
.#
..
#.
..
.#
..
#.
..
.#
..
#.
..
.#
..
#.
..
..
#.
..
.#
..
..
#.
..
.#
..
..
#.
..
..
#.
..
..
.#
..
#.
..
.#
..
#.
..
..
#.
..
..
#.
..
..
#.
..
..
..
#.
..
..
#.
..
....

output:

1692129038
30925794
178424122
188960346
2571723864
1528829980
1255108454
871149625
1812938455
593627532
64699598
2412291153
317769272
3202278445
2157756707
1358708242
1937020369
1225052687
353024485
672971398
928395324
567287042
170886760
342019193
750419560
18392541
275588624
1082155153
1835256780
...

result:

ok 50 lines

Test #23:

score: 0
Accepted
time: 24ms
memory: 13360kb

input:

111
30 30 939138499 974051969
...#..#..#...#..#...#..#..#..#
.#.........#......#...........
.....#..#............#..#..#..
#.........#..#..#..#.........#
..#...#...............#..#....
........#...#..#..#........#..
#..#......#.........#..#.....#
......#......#..#........#....
.#..#...#..#......#......

output:

5634830994
9780654334
12403191944
10804777192
5893846136
9891290400
9590069680
8446617864
8397261500
9249901010
10976549328
11589151002
8901143184
7004180008
10669867384
11934400374
11111857029
9357628280
11021698944
8649032800
10367647510
6337875800
6812873690
12960213734
8776350429
7474828816
6277...

result:

ok 111 lines

Test #24:

score: 0
Accepted
time: 27ms
memory: 17180kb

input:

111
30 30 1216253 105180
...#..#..#..#...#..#..#..#..#.
..............................
..#..#..#..#...#..#....#..#..#
#............#......#.........
...#..#..#......#.....#..#..#.
.#.........#.......#..........
....#..#......#......#..#..#..
..#......#..#...#............#
#....#.............#...#..#...

output:

13716032
10901676
53206464
35538203
25363311
7005123
17832078
35862536
2146884
16218420
52601204
8143104
12095440
42702286
2253192
7089435
42510747
15592692
29722090
11070702
56746519
33386419
77391677
32480632
46192757
24357346
16561790
19915570
25692935
16546590
78783572
32564664
3593580
38664814
...

result:

ok 111 lines

Test #25:

score: 0
Accepted
time: 22ms
memory: 14464kb

input:

1000
10 10 981842436 964970591
...#..#..#
..........
#...#...#.
..#...#...
.........#
#..#...#..
.....#....
.#......#.
...#..#...
#........#
885767930 687873897 838112261 888459206 959811877 960808377 940033924 923742552 955584370 911814229
917068874 941608713 945044030 939768541 899312479 966876137...

output:

5891054616
4489664965
3645442648
3393699700
3995148664
4724272155
5360495724
3901837604
4991772580
5308248828
2920699071
3555201600
2710203980
3934557044
3375417588
2967020214
4700586010
3779301220
2765967288
3393713204
4605128580
4092010090
3316517528
3632316484
2941207911
1995302114
3705108728
492...

result:

ok 1000 lines

Test #26:

score: 0
Accepted
time: 26ms
memory: 14600kb

input:

1000
10 10 3466470 309750
..#...#..#
....#.....
#......#..
..#..#....
.........#
#..#..#...
........#.
.#...#....
...#...#..
#........#
1231404 11407893 8640654 14348765 3099095 437441 709549 45575 3016394 4932165
3906936 4573023 2919259 292586 855083 1135844 1411127 31122 292379 6516073
2606701 433...

output:

17120729
4509164
2826720
12378624
31070403
7406589
8563744
10692920
2322480
15403292
1450125
22970599
26119769
2257140
10555192
10856762
1151708
6387312
133605
17459945
212470
18276414
484240
1194189
12788408
8574948
7012148
18994295
3126384
20079512
14838060
3146088
28363545
1182344
7344716
1059412...

result:

ok 1000 lines

Test #27:

score: 0
Accepted
time: 19ms
memory: 14048kb

input:

25000
2 2 715730798 969518871
..
.#
997352031 945784830
938787786 879675296
2 2 811011394 786705734
..
.#
816288991 986642299
948200241 806401856
2 2 908482925 941285764
..
.#
991370951 974856657
981074310 975385990
2 2 997891660 986018307
..
.#
975546599 790594080
838130350 876132281
2 2 924950960 ...

output:

715730798
811011394
908482925
997891660
924950960
931411692
921532529
938322545
866327958
0
0
945467847
911823757
965420281
727581203
951925362
979077384
985258431
991606744
903930871
961095577
866233235
942989231
948856365
0
448046921
0
980724408
936267890
0
838515408
793724883
0
969122654
0
922333...

result:

ok 25000 lines

Test #28:

score: 0
Accepted
time: 22ms
memory: 13788kb

input:

25000
2 2 2649160 63173457
..
.#
14725275 26011159
13027002 10060620
2 2 12962051 11294386
..
.#
20104520 13150476
2957041 4954318
2 2 32549864 1050435
..
.#
201076 6680627
5070644 6518417
2 2 12767553 1679886
..
.#
12343100 8770625
7585694 5374647
2 2 6296530 20371820
..
.#
14419138 3993549
1000456...

output:

2649160
12962051
32549864
12767553
6296530
7100604
3474892
0
4533850
4294661
0
5982508
3001367
480129
0
0
22581114
12425908
0
9495642
2214432
10571884
0
0
0
5741341
3870859
4122466
5979538
11904546
9565347
5020745
0
17142924
2680251
4687408
168506
6315436
7964006
0
37409
10162333
0
37258500
3104166
...

result:

ok 25000 lines

Test #29:

score: 0
Accepted
time: 52ms
memory: 31568kb

input:

1
315 315 820754300 947845899
..#....#...#....#....#..#..#....#..#..#....#.....#..#..#...#...#..#...#...#..#...#..#.....#..#....#..#....#..#..#.....#...#.....#..#....#...#....#..#......#.......#..#....#..#....#...#.....#..#..#...#..#.....#..#..#...#.....#....#..#...#..#..#..#..#......#....#..#..#......

output:

34471680600

result:

ok single line: '34471680600'

Test #30:

score: 0
Accepted
time: 55ms
memory: 31392kb

input:

1
315 315 3280374 166177
..#...#..#..#....#..#......#..#.....#..#..#....#..#..#...#...#....#..#....#..#...#...#..#...#..#...#..#...#......#....#...#....#...#....#..#...#....#..#...#.....#....#..#..#...#..#..#....#..#..#....#..#..#....#..#..#..#..#..#...#....#....#..#..#..#.....#..#...#..#...#...#......

output:

113296649

result:

ok single line: '113296649'

Test #31:

score: 0
Accepted
time: 14ms
memory: 17380kb

input:

50
2 1000 997462743 938677307
...#..#.....#...#..#...#...#.....#...#..#...#..#...#..#...#..#..#..#...#..#...#..#....#...#...#..#...#..#....#..#...#..#...#...#..#.......#..#..#..#..#....#...#..#..#...#....#........#..#..#....#..#..#..#...#..#..#.....#....#....#.......#...#..#....#.............#...#.....

output:

347117034564
329596073556
328203563910
330173100656
332950452570
307775601000
315841746671
336349987304
315273371216
336857154738
306098188028
324786829353
330296051704
332562981072
328623562956
333941739252
335256635328
294470066702
301209370858
333020948850
190909242776
315747658314
325807038036
3...

result:

ok 50 lines

Test #32:

score: 0
Accepted
time: 18ms
memory: 13500kb

input:

50
2 1000 729952 1823090
...#..#....#..#..#..#..#..#..#...#..#..#..#..#..#.....#....#...#...#...#..#.....#....#..#..#....#...#..#..........#..#...#..#...#...#..#....#..#..#.......#..#..#...#...#.....#..#..#..#..#..#.....#...#....#..#......#...#..#..#...#..#...#..#.....#....#..#..#..#..#..#..#....#.....

output:

244533920
1180631053
2852723727
429738777
1054474404
1603493838
32522616
468350444
1307054163
65869969
214192560
929487649
1954347772
329610708
1245542844
348161978
347828032
283637288
255643045
564881382
613718245
1385338240
217345167
1486991058
1212893334
132711056
1346235052
3312201092
3497041328...

result:

ok 50 lines

Test #33:

score: 0
Accepted
time: 15ms
memory: 19264kb

input:

50
1000 2 574276630 932663810
..
..
..
..
.#
..
#.
..
..
.#
..
#.
..
..
.#
..
#.
..
..
#.
..
..
#.
..
.#
..
#.
..
.#
..
..
..
#.
..
..
.#
..
..
#.
..
.#
..
..
#.
..
.#
..
#.
..
.#
..
#.
..
..
..
#.
..
..
#.
..
.#
..
#.
..
.#
..
..
#.
..
.#
..
#.
..
.#
..
..
#.
..
.#
..
#.
..
.#
..
..
#.
..
..
#.
..
...

output:

215353736250
361739210568
155975265992
370882686600
371539553189
357403169926
348637205322
380520436072
356098206744
343400523060
356867193000
311870327712
359756451072
347242026438
373271215842
318781864884
362728130268
366599129532
367357625625
348980445632
363365474945
345261341752
373810063125
3...

result:

ok 50 lines

Test #34:

score: 0
Accepted
time: 19ms
memory: 19372kb

input:

50
1000 2 1238487 6305503
..
..
.#
..
..
..
.#
..
#.
..
..
#.
..
..
..
..
#.
..
.#
..
..
#.
..
..
..
.#
..
..
#.
..
.#
..
..
..
..
..
#.
..
.#
..
#.
..
.#
..
..
#.
..
.#
..
..
#.
..
.#
..
#.
..
..
#.
..
.#
..
#.
..
..
#.
..
..
#.
..
.#
..
#.
..
.#
..
..
..
#.
..
.#
..
..
..
#.
..
.#
..
#.
..
.#
..
....

output:

464432625
965915394
492694050
413858000
1628067890
674851584
645081980
552935929
467519385
1008503244
1733049079
1984169051
427280788
455021046
423077594
916034530
1631504529
2876698055
799186995
884332945
290072530
638813318
3929178381
333622330
869716225
1475996113
269338788
796167528
1325527777
1...

result:

ok 50 lines

Test #35:

score: 0
Accepted
time: 27ms
memory: 13452kb

input:

111
30 30 855122138 819273225
..#.....#...#..#..#...#.....#.
..........#.........#...#.....
#..#..#......#..#.........#..#
........#..#.......#...#......
.....#........#..........#....
.#.....#..#.....#....#.....#..
............#......#....#.....
#..#..#..#....#..#....#...#..#
...........#........#....

output:

5130732828
4166848505
5500423536
5650314900
4482371685
4302133205
4148089505
6676218836
3971474300
5280191400
6651913282
6794357969
3601338744
8978282145
6678779898
6743640393
5139053814
3993994566
4853306580
5285135148
3867184696
7960836992
6039612327
3503377225
4896458280
7363200960
6982099075
393...

result:

ok 111 lines

Test #36:

score: 0
Accepted
time: 28ms
memory: 13892kb

input:

111
30 30 6436156 2257667
......#..#....#..#..#..#..#..#
...#.......#..................
#....#..#......#..#...#.....#.
..#..........#..........#.....
......#..#.......#...#....#...
.#..#.........#........#......
........#..#....#..#.......#..
.............#........#......#
#..#...........#....#....#...

output:

50337763
23196922
6313866
8593970
14826744
10344120
55521
2248830
16534830
10479
25243792
11452356
5874280
201070
37893630
27202417
11066400
14018497
11955568
8048349
38108242
32899447
19715280
35666075
4742245
30621788
3588954
3766206
27365304
8483725
13244400
36293181
4233240
9898190
13863538
2737...

result:

ok 111 lines

Test #37:

score: 0
Accepted
time: 23ms
memory: 14780kb

input:

1000
10 10 890670715 954685660
..#..#...#
.......#..
#..#......
......#..#
....#.....
#.........
..#....#..
..........
....#.....
..#...#...
984282271 943646083 883856629 841431621 997121812 940374513 950424600 949598781 894056449 732320925
943672310 957214963 919698827 676023499 833560013 789747253...

output:

890670715
1734229732
1467354956
1988251028
2888424200
2949806259
1996838812
1594836752
2923800846
2985116211
1923681356
1992523052
2726766096
2962758474
768284038
634082587
2949485217
2938203486
1984213844
2912826870
1941187080
3862288300
1849331154
1885160924
3141356404
2920693344
3884481792
167414...

result:

ok 1000 lines

Test #38:

score: 0
Accepted
time: 25ms
memory: 17008kb

input:

1000
10 10 734742 2659784
...#.....#
.#.....#..
.....#....
#..#.....#
......#...
..#.....#.
..........
.#..#..#..
..........
...#..#...
9042088 29219 6810220 1060471 562362 252382 3513871 4148436 1582704 1642603
1990615 2311243 7619909 4038320 6712331 6737027 5972565 3865365 264217 8994608
4268405 1...

output:

2204226
1252892
16184760
9983410
19323670
1572381
635648
654416
3756752
14979870
4706933
4961400
1173112
19703774
14353595
20141052
5217845
7483171
1565805
2739538
29647516
1377978
9809001
12875549
415197
770696
4217494
34217378
549084
8073408
12528684
4617015
8115036
9107601
3496979
1722264
3374958...

result:

ok 1000 lines

Test #39:

score: 0
Accepted
time: 21ms
memory: 14880kb

input:

25000
2 2 985241436 978514993
..
..
924177730 936190490
988705056 958780743
2 2 847167734 998213512
..
..
989027181 714240802
890311232 991893817
2 2 964667839 979722494
..
..
912967908 897547947
917257507 934795250
2 2 988069126 999435927
..
.#
975983143 797505870
837219197 782456193
2 2 966400061 ...

output:

0
0
0
988069126
966400061
989273655
781806377
0
965120622
0
0
974936573
0
0
0
0
997987276
969544953
0
775427280
0
995217910
0
863738019
0
0
929576210
0
0
0
961153816
857572358
981739230
987490401
0
0
831091065
925254948
944253461
762537665
989264755
993072413
0
914298436
0
0
0
970243020
0
977423505
...

result:

ok 25000 lines

Test #40:

score: 0
Accepted
time: 22ms
memory: 14388kb

input:

25000
2 2 1428517 3052849
..
.#
8651097 14067
6574243 2142968
2 2 77015 595874
..
.#
1986589 6388640
3139108 1740536
2 2 3781298 2824580
..
..
1877747 989250
3555695 3233019
2 2 5176597 4687226
..
..
1884259 135683
3995529 1779625
2 2 1583632 4179261
..
..
2236782 6297370
1328977 3119002
2 2 11093 1...

output:

1428517
77015
0
0
0
0
1751008
0
7666641
0
0
0
4456135
7543019
0
0
0
809235
0
0
0
0
3259943
1449455
2526104
938198
0
0
280316
3051159
626998
0
6244742
0
0
10404808
1882403
727759
4901829
0
1889869
0
2049414
0
0
3405973
0
1280377
0
0
0
1703109
0
2544626
0
0
975385
0
1183881
1314753
7795968
12611489
0
...

result:

ok 25000 lines

Test #41:

score: 0
Accepted
time: 66ms
memory: 35088kb

input:

1
315 315 959982785 762371133
..#..#...#.....#...#..#....#.....#...#..#..#......#.......#...#..#...#....#..#..#..#..........#..#..........#...#...#...#.........#....#..#..#........#..#....#..............#...#......#..#....#...........#......#..........#.....#......#...#...#...#........#..#......#..#...

output:

959982785

result:

ok single line: '959982785'

Test #42:

score: 0
Accepted
time: 67ms
memory: 32412kb

input:

1
315 315 249995 916792
.....#..#.....#....#.........#.....#.....#....#..#.....#..#..#..#...#............#..#....#..#....#.....#...#........#.......#....#.....#....#..#...#...#.....#..#.....#.......#....#..#..#..#......#........#..#...#....#.....#....#....#.....#........#....#....#.............#..#....

output:

749985

result:

ok single line: '749985'

Test #43:

score: 0
Accepted
time: 16ms
memory: 14372kb

input:

50
2 1000 866396873 888015008
.....#...#........#...........#..#....#..#..#...#.........#...#.....#...............#.............#.....#...#...#..#....#............#....#.........#...#..#.......#..#.....#....#...#..#...#.............#..#..................#....#....#..#..#..#..#.........#.....#..........

output:

239991933821
189740769362
242870382615
175922855296
251788109385
251146491534
232363259727
226846514104
244336446272
255060979558
238599062830
220106617785
252909531239
223286430744
248032652310
244623157267
251776020480
237238319097
235210555044
253823974677
197486857620
242313789766
235501554490
1...

result:

ok 50 lines

Test #44:

score: 0
Accepted
time: 20ms
memory: 13564kb

input:

50
2 1000 3404620 3166744
....#......#.....#....#........#....#............#..#...#........#..#.........#.......#....#...#...#..#...#....#...#..#....#...#......#..#.......#...#....#....#.....#....#.......#...#..#............#....#.....#........#......#......#..#......#...#.............#.....#..#.......

output:

870949815
740984040
706774068
882849283
586319184
527624592
1373660446
128467776
942931497
2321155995
807635815
1366640533
1695744556
731953221
1663710953
1105728612
1180803978
333825113
253301226
1872990779
1643956671
1181856456
1576446560
518569518
656944992
145615536
945896135
758885285
985613973...

result:

ok 50 lines

Test #45:

score: 0
Accepted
time: 19ms
memory: 19024kb

input:

50
1000 2 966557522 809726481
..
..
..
#.
..
..
..
.#
..
..
..
..
..
..
..
..
..
#.
..
..
..
.#
..
..
.#
..
..
..
..
..
..
..
..
..
..
.#
..
#.
..
..
..
#.
..
..
#.
..
..
.#
..
..
..
#.
..
..
#.
..
..
..
#.
..
..
..
..
.#
..
#.
..
..
..
..
.#
..
..
..
#.
..
..
..
..
#.
..
.#
..
..
..
#.
..
..
..
..
...

output:

257104300852
261619002298
232855209440
271608916496
244065883652
267862860908
264466682834
262153942869
212243489120
249305000367
231806775928
251077570144
235171599480
226358036554
250222359114
248604776622
264159702034
265987256346
283913192172
251560505124
239969183958
256650801225
274126600146
2...

result:

ok 50 lines

Test #46:

score: 0
Accepted
time: 18ms
memory: 19144kb

input:

50
1000 2 4672441 147672
..
.#
..
..
#.
..
..
..
..
#.
..
..
..
#.
..
..
..
#.
..
..
..
..
.#
..
#.
..
..
..
#.
..
.#
..
..
..
..
..
..
..
..
#.
..
.#
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
#.
..
.#
..
..
.#
..
..
.#
..
#.
..
..
..
..
.#
..
..
.#
..
..
..
..
..
#.
..
.#
..
#.
..
.#
..
..
..
.#...

output:

987323021
129248559
137247950
661265076
493601797
517243544
2418871739
274973692
1473470947
125095432
502824912
322330281
1930885586
110085064
711715206
133876120
688864536
512154521
742297914
775536675
917017489
1089314491
47076345
974496228
31162530
654025904
1240311350
886501113
792070884
5155612...

result:

ok 50 lines

Test #47:

score: 0
Accepted
time: 28ms
memory: 17016kb

input:

111
30 30 984695547 951189840
......#.........#...#....#...#
.#......#...#.....#...#.......
.....#.....................#..
..........#..#..........#.....
....#..#........#.............
.........#..#...............#.
..#...........#...#....#......
#...#..#...#....#...#........#
.........................

output:

4923477735
2496067767
778547066
2826495975
948162690
2622037452
948691796
933062145
975005338
1964878306
2689874544
1736628026
953942554
2791115187
0
1981697556
2952947601
0
1507796264
845273039
931676233
1462528604
0
0
1295782452
1997967090
1951629724
2966687055
3714995768
1979356608
2907021675
180...

result:

ok 111 lines

Test #48:

score: 0
Accepted
time: 31ms
memory: 13680kb

input:

111
30 30 1190161 3841022
.........#................#..#
...........#......#..#........
.#..#...#....#.........#......
......#...#....#.........#...#
...#.................#........
.#......#.......#.........#...
..........#...........#.......
...#........#..#...#....#..#..
.#.....#.........#...........

output:

2380322
8522272
25449273
681936
468129
2876254
2712316
1621606
3011992
9743692
8538600
6025944
10996350
2327832
14839020
14794468
3136432
11651868
3753534
2109248
1930434
13237540
14103198
3227612
2688558
2251555
6743246
17769566
9981232
13868118
10623879
0
4307992
21184658
36897512
6155030
21788230...

result:

ok 111 lines

Test #49:

score: 0
Accepted
time: 25ms
memory: 14024kb

input:

1000
10 10 851415279 890799569
.......#..
..........
#..#....#.
..........
.#...#....
..........
..........
.#...#....
..........
..#.....#.
934087793 966005023 916993301 875064609 997453356 936647322 828142094 981930269 995349906 993402110
955373370 955777377 964393697 954218513 985241222 851272002...

output:

851415279
993794143
1803767382
0
1886368418
1902324088
884359610
2396338749
954157374
1582563558
0
0
1918431588
0
981542203
2195385429
1724204480
0
0
1994965142
1780231080
1616702554
911863236
1990580902
1635955738
940118631
908872634
1926428758
925485948
974916876
1975746738
1838085328
0
2586482031...

result:

ok 1000 lines

Test #50:

score: 0
Accepted
time: 26ms
memory: 14588kb

input:

1000
10 10 3415334 4514957
....#..#..
..#.......
#.......#.
...#..#...
.#........
.........#
......#...
#..#....#.
..........
..........
2404401 2235011 5319133 1087307 735772 690677 2132263 938829 4911818 3537012
918117 4165583 3668573 2857912 974294 1929276 2207953 11768666 2065820 882758
688649 4...

output:

6830668
2820956
458330
0
4481820
67674
376100
2463489
0
19567015
2604105
1299824
14715607
1773429
13535966
4781972
5887603
0
915970
8094141
5938403
5538588
6491932
456286
1104794
13284996
4877173
545192
1157294
1375859
4209240
1667212
760744
235348
5562920
0
4021544
1356674
1537797
0
12051676
109292...

result:

ok 1000 lines

Test #51:

score: 0
Accepted
time: 13ms
memory: 13804kb

input:

25000
2 2 968945576 883722487
..
..
975822974 925735696
842724638 998672386
2 2 851401198 981363474
..
..
925051352 984791260
993579453 991275709
2 2 986322676 914412590
..
..
953043779 993990192
995953568 902911280
2 2 901764107 921456421
..
..
911071248 672737303
963318928 961436259
2 2 895927714 ...

output:

0
0
0
0
0
892782287
0
901649886
0
0
0
0
0
0
0
997718559
992938104
0
0
0
884199412
0
0
0
0
0
726169109
0
940960884
853332720
0
0
0
0
0
978916031
0
0
0
969606590
967206234
0
849205839
0
0
0
0
0
0
0
976598261
0
0
0
0
0
0
975241508
0
0
0
0
0
0
0
0
0
994649641
0
0
0
936196726
0
0
0
0
0
938583921
0
0
0
0
...

result:

ok 25000 lines

Test #52:

score: 0
Accepted
time: 16ms
memory: 13404kb

input:

25000
2 2 5236916 5235997
..
..
658303 225343
2570227 2446192
2 2 4489953 11839164
..
..
6490928 296605
3224607 2419082
2 2 6481050 5473757
..
..
572611 3089414
3454646 11341301
2 2 392343 1333706
..
..
3233325 1450818
1006539 5073915
2 2 980324 1710456
..
..
1231312 3463740
1444635 1451065
2 2 1024...

output:

0
0
0
0
0
10246402
0
5158631
0
0
2338362
0
0
0
1127062
0
1580227
0
0
0
0
0
0
10386530
0
1423404
0
0
0
783472
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1663979
0
0
0
0
0
471699
0
0
0
0
0
0
0
0
0
0
0
902619
0
139446
0
2327513
1754775
0
0
0
0
0
0
0
0
629352
0
0
0
0
0
0
0
3966031
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0...

result:

ok 25000 lines

Test #53:

score: 0
Accepted
time: 24ms
memory: 14216kb

input:

3333
3 10 2187 6681
..#.......
....#..#..
#........#
1358 0 5607 2773 666 451 10619 8135 3062 2337
2125 807 10160 4121 129 6577 6225 2417 986 3025
2763 7559 1956 1876 388 535 3029 39 774 2544
3 10 323 942
....#.....
........#.
#.....#...
187 1036 769 1185 3737 2360 1068 4608 5683 5172
1717 702 5214 ...

output:

6561
323
6454
3610
3471
4212
5362
47520
718
2168
8656
15821
2240
27249
1392
1070
162
8942
18924
19380
13284
2112
2536
4278
10083
912
21434
536
3042
36117
14152
786
7440
0
6447
37530
9708
1768
5652
11024
1497
13836
8952
10503
5756
14640
18520
10400
860
390
2514
1752
14202
10212
23781
9030
15060
14633...

result:

ok 3333 lines

Test #54:

score: 0
Accepted
time: 23ms
memory: 13728kb

input:

840
17 7 3524 8478
...#...
.....#.
#......
...#...
.......
#...#..
..#...#
.......
.#..#..
.......
..#...#
#......
...#...
......#
#...#..
..#....
.....#.
198 5773 4727 5037 1658 3149 3588
2386 4580 1222 1081 14042 2721 2886
3118 4837 3266 17633 43 2015 2920
2428 2779 1667 459 4560 7399 11940
3351 1...

output:

14096
49837
7122
14686
61460
4101
2997
2755
320
3540
3580
20125
1878
17540
4690
31752
15058
13165
582
2187
3387
14252
256
3312
34355
53688
5259
2112
29600
8130
4225
21420
31477
6086
10524
1218
10496
2900
8268
2421
23443
1236
1791
10356
6992
4497
30073
5455
4164
9618
11616
12755
16914
33030
13032
148...

result:

ok 840 lines

Test #55:

score: 0
Accepted
time: 21ms
memory: 13872kb

input:

3333
3 10 8907 1719
..#...#..#
....#.....
#......#..
7568 5515 9649 1734 1466 1836 3224 5425 628 5771
9948 2039 2459 4157 3899 1876 4529 5783 6360 5673
882 3050 3042 591 1139 4122 692 6314 6591 1746
3 10 1838 289
..#..#..#.
..........
....#..#..
1839 1953 1363 877 9410 288 1528 1224 713 3206
7678 17...

output:

14525
3089
13144
4154
9525
3627
6510
5670
12848
32
992
13656
16917
8330
732
15264
17137
7462
5998
2014
4262
11922
12931
26812
18804
10883
450
968
6784
3334
11385
18210
27104
9184
6210
3024
12216
10719
14640
1770
6798
1370
14175
1162
15918
19892
12630
4260
17963
4332
9248
1910
11020
17537
10348
9450
...

result:

ok 3333 lines

Test #56:

score: 0
Accepted
time: 21ms
memory: 14620kb

input:

840
17 7 361 2048
.......
.#..#..
......#
#..#...
.....#.
.#.....
...#..#
.......
#...#..
......#
.#.....
...#...
.....#.
.......
#......
..#..#.
.......
1693 4451 5322 2560 2803 6337 3125
1208 10314 812 814 1703 7600 1883
8667 2783 3211 2048 2853 8130 3430
543 484 4534 4871 27 3371 3621
4450 396 39...

output:

1805
4004
7984
26646
5802
2460
25972
15180
6420
6936
4560
40934
8460
26745
30
7080
34171
25160
14040
2760
10376
3385
20860
3900
7810
2712
382
7275
6132
4518
13392
6324
7539
6490
28170
19401
17400
4544
5030
6482
20195
8648
2177
7194
27144
2065
9336
3585
7589
8142
25811
486
6294
25270
30153
6006
8239
...

result:

ok 840 lines

Extra Test:

score: 0
Extra Test Passed