UOJ Logo

NOI.AC

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#200676#149. Babywosile1003217ms36812kbC++112.0kb2024-01-09 10:34:212024-01-09 12:13:01

answer

#include<bits/stdc++.h>
using namespace std;
int n,m,Q;
int T[500005][4];
int rec[2000005];
int tot=0;
int pos[500005][4];
struct query{
	int s,t;
	int id;
	int dir;
	int sp;
	bool operator <(const query &o)const{
		return sp>o.sp;
	}
}q[100005];
char s[200005];
void walk(int x,int d){
	// printf("%d %d %d %d\n",x,d,tot,2*n*m-2);
	if(tot==n*m*2-2)return;
	rec[++tot]=x;
	d=(d-1)&3;
	while(!T[x][d])d=(d+1)&3;
	pos[x][d]=tot;
	walk(T[x][d],d);
}
inline int id(int x,int y){
	return (x-1)*m+y;
}
int lp[500005],ft[2000005],ans[500005];
void add(int x,int v){
	for(;x<=tot+tot;x+=(x&-x))ft[x]+=v;
}
int query(int x){
	int sum=0;
	for(;x;x-=(x&-x))sum+=ft[x];
	return sum;
}
int main(){
	scanf("%d%d%d",&n,&m,&Q);
	for(int i=1;i<=n;i++){
		scanf("%s",s+1);
		if(i>1){
			for(int j=1;j<=m;j++)if(s[j+j]=='.'){
				T[id(i-1,j)][2]=id(i,j);
				T[id(i,j)][0]=id(i-1,j);
				// printf("conn %d %d\n",id(i-1,j),id(i,j));
			}
		}
		scanf("%s",s+1);
		for(int j=1;j<m;j++)if(s[j+j+1]=='.'){
			T[id(i,j)][3]=id(i,j+1);
			T[id(i,j+1)][1]=id(i,j);
			// printf("conn %d %d\n",id(i,j),id(i,j+1));
		}
	}
	scanf("%s",s+1);
	for(int i=1;i<=Q;i++){
		int sx,sy,tx,ty;
		scanf("%d%d%d%d",&sx,&sy,&tx,&ty);
		scanf("%s",s);
		int d=0;
		if(s[0]=='U')d=0;
		if(s[0]=='L')d=1;
		if(s[0]=='D')d=2;
		if(s[0]=='R')d=3;
		q[i].s=id(sx,sy);
		q[i].t=id(tx,ty);
		while(!T[q[i].s][d])d=(d+1)&3;
		q[i].dir=d;
		q[i].id=i;
	}
	// printf("shit\n");
	// return 0;
	walk(1,0);
	// for(int i=1;i<=tot;i++)printf("%d ",rec[i]);
	// printf("\n");
	for(int i=1;i<=tot;i++)rec[i+tot]=rec[i];
	for(int i=1;i<=Q;i++)q[i].sp=pos[q[i].s][q[i].dir];
	sort(q+1,q+Q+1);
	int qwq=tot+tot+1;
	for(int i=1;i<=Q;i++){
		while(qwq>q[i].sp){
			--qwq;
			int v=rec[qwq];
			if(lp[v])add(lp[v],-1);
			add(qwq,1);
			lp[v]=qwq;
		}
		ans[q[i].id]=query(lp[q[i].t]);
	}
	for(int i=1;i<=Q;i++)printf("%d\n",ans[i]);
	return 0;
}
// quod erat demonstrandum

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

详细

小提示:点击横条可展开更详细的信息

Subtask #1:

score: 19
Accepted

Test #1:

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

input:

96 96 100
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-...

output:

1326
480
3387
6167
4518
4048
7029
7371
5287
2234
3167
101
9051
3563
4707
6040
4089
4875
952
2232
294...

result:

ok 100 numbers

Test #2:

score: 0
Accepted
time: 2ms
memory: 1856kb

input:

97 97 98
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+...

output:

4737
7617
6676
4617
8684
1673
590
1474
1822
560
5132
2562
6984
506
855
6821
6616
8993
3874
9118
9064...

result:

ok 98 numbers

Test #3:

score: 0
Accepted
time: 2ms
memory: 1868kb

input:

98 98 96
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+...

output:

8954
4381
2711
4374
1178
6103
5363
214
4559
2788
6687
596
4852
722
9461
1822
1001
2502
4305
3645
384...

result:

ok 96 numbers

Test #4:

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

input:

99 99 100
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-...

output:

9464
8879
489
4805
5486
5316
8052
6111
9545
8948
6558
1198
8288
9510
9586
2003
1060
6538
1538
9214
1...

result:

ok 100 numbers

Test #5:

score: 0
Accepted
time: 2ms
memory: 1900kb

input:

100 100 99
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+...

output:

6565
4740
6383
9269
3598
3018
4060
9849
6090
9678
8514
4734
1122
431
230
338
6071
5525
741
4395
5584...

result:

ok 99 numbers

Test #6:

score: 0
Accepted
time: 2ms
memory: 1840kb

input:

95 95 97
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+...

output:

2498
7978
1776
6457
3398
2237
2310
934
872
2669
1523
2274
6748
3719
1380
3672
1034
8571
8334
8728
69...

result:

ok 97 numbers

Test #7:

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

input:

96 96 95
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+...

output:

8417
6133
7121
4402
9075
6283
6635
5396
4819
449
2710
3732
5785
1752
7883
5872
2077
4068
6912
8259
5...

result:

ok 95 numbers

Test #8:

score: 0
Accepted
time: 3ms
memory: 1856kb

input:

96 97 99
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+...

output:

771
4153
1652
7418
7216
6980
7918
6436
4083
7569
777
4396
8734
8361
995
4801
8099
5746
4734
7503
454...

result:

ok 99 numbers

Test #9:

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

input:

98 97 98
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+...

output:

1990
7656
2966
520
6022
5718
6486
664
2096
4931
1079
4053
6852
2908
8231
4598
7966
4430
8750
5105
71...

result:

ok 98 numbers

Test #10:

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

input:

99 98 96
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+...

output:

6797
3220
6888
3795
2005
4142
7170
2046
2093
8135
4266
4788
6394
7594
7730
5243
9133
2814
7070
7912
...

result:

ok 96 numbers

Subtask #2:

score: 22
Accepted

Test #11:

score: 22
Accepted
time: 146ms
memory: 28800kb

input:

97182 4 74935
+-+-+-+-+
|.......|
+-+-+.+-+
|.|.|...|
+.+.+-+.+
|.......|
+.+-+-+-+
|.......|
+.+-+-...

output:

48469
78681
124416
159371
130474
345308
254383
301594
41731
85485
253030
275060
233837
153931
4748
1...

result:

ok 74935 numbers

Test #12:

score: 0
Accepted
time: 134ms
memory: 28884kb

input:

100000 4 46609
+-+-+-+-+
|...|...|
+.+.+.+.+
|.|...|.|
+.+-+-+.+
|...|.|.|
+.+-+.+.+
|.....|.|
+.+-+...

output:

63922
359352
67222
236082
340569
339831
351253
381252
182075
31818
206412
350861
327937
39883
370174...

result:

ok 46609 numbers

Test #13:

score: 0
Accepted
time: 150ms
memory: 29524kb

input:

99419 4 80456
+-+-+-+-+
|.......|
+.+.+-+.+
|.|.|.|.|
+-+.+.+.+
|...|...|
+.+-+-+-+
|.|.....|
+.+.+-...

output:

249593
302021
366992
350009
386754
313153
345276
2946
339163
392085
103564
100801
2558
135299
157006...

result:

ok 80456 numbers

Test #14:

score: 0
Accepted
time: 126ms
memory: 28676kb

input:

98706 4 52130
+-+-+-+-+
|.|.....|
+.+.+-+.+
|.....|.|
+-+-+.+.+
|.....|.|
+.+-+-+.+
|.|.|...|
+.+.+....

output:

227571
249383
390252
379565
357894
30489
140989
283752
338296
266276
172220
38170
141395
266646
2203...

result:

ok 52130 numbers

Test #15:

score: 0
Accepted
time: 107ms
memory: 27760kb

input:

97772 4 23804
+-+-+-+-+
|.......|
+.+-+-+.+
|.|.|...|
+.+.+-+.+
|.....|.|
+.+.+-+-+
|.|.....|
+.+-+-...

output:

187754
272816
1031
387229
139045
17613
180790
125325
390229
85175
319858
119501
228344
308130
217705...

result:

ok 23804 numbers

Test #16:

score: 0
Accepted
time: 157ms
memory: 29112kb

input:

96545 4 95479
+-+-+-+-+
|.......|
+.+-+.+.+
|...|.|.|
+-+.+.+.+
|...|.|.|
+.+-+.+.+
|...|.|.|
+.+-+....

output:

31648
314158
92577
65057
133577
318325
25503
81163
188763
201157
2773
96180
113963
306992
212163
348...

result:

ok 95479 numbers

Test #17:

score: 0
Accepted
time: 109ms
memory: 27292kb

input:

95537 4 29325
+-+-+-+-+
|.|.....|
+.+.+-+.+
|...|...|
+.+-+.+-+
|...|.|.|
+-+.+.+.+
|.|.|...|
+.+.+-...

output:

46246
114354
331005
132841
94429
277644
186097
332377
158353
209523
117509
233759
333325
304728
2666...

result:

ok 29325 numbers

Subtask #3:

score: 21
Accepted

Test #18:

score: 21
Accepted
time: 44ms
memory: 3896kb

input:

10 500 99779
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+...

output:

4541
2045
4406
4209
3893
2580
2661
1999
4627
488
1820
4507
3297
576
3267
4681
3816
1608
3121
4079
27...

result:

ok 99779 numbers

Test #19:

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

input:

138 36 99514
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|...............

output:

2574
3868
3494
2715
1484
3329
4664
387
632
302
4689
1585
434
2797
3657
2334
2181
3026
1310
3541
2075...

result:

ok 99514 numbers

Test #20:

score: 0
Accepted
time: 44ms
memory: 3872kb

input:

34 144 99249
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+...

output:

2869
3662
3561
665
2368
1331
2215
2317
846
1632
578
971
4077
1240
1856
2127
3545
390
580
1190
3457
3...

result:

ok 99249 numbers

Test #21:

score: 0
Accepted
time: 48ms
memory: 3888kb

input:

416 12 99293
+-+-+-+-+-+-+-+-+-+-+-+-+
|.......|.............|.|
+.+-+.+-+.+-+-+.+.+-+.+.+
|...|.......

output:

3802
4594
1171
3536
1105
530
4276
1830
728
2328
587
4943
4980
3569
1380
63
4638
4654
3
3119
3167
252...

result:

ok 99293 numbers

Test #22:

score: 0
Accepted
time: 45ms
memory: 3884kb

input:

7 714 99028
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-...

output:

2963
2798
4695
2062
765
3665
3309
1508
311
311
116
1873
1541
3294
442
4249
2834
4592
3447
3919
4524
...

result:

ok 99028 numbers

Test #23:

score: 0
Accepted
time: 37ms
memory: 3884kb

input:

24 208 99764
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+...

output:

2278
2603
3096
173
1624
775
4169
1601
1588
3843
2972
2234
1117
3277
3236
49
61
2387
2137
794
140
627...

result:

ok 99764 numbers

Test #24:

score: 0
Accepted
time: 44ms
memory: 3884kb

input:

416 12 99499
+-+-+-+-+-+-+-+-+-+-+-+-+
|.......|...|.|.........|
+.+.+-+.+.+-+.+.+-+-+.+-+
|.|.|...|...

output:

1412
74
2833
3062
1187
1934
4479
3362
1115
3225
1966
1148
687
3092
2832
2763
3914
3092
2811
1827
361...

result:

ok 99499 numbers

Test #25:

score: 0
Accepted
time: 43ms
memory: 3896kb

input:

138 36 99543
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|.|.....|...|...

output:

1104
4841
247
3163
1855
1438
4208
2017
4281
4432
880
4864
2716
2270
3585
3821
982
4929
398
4137
1397...

result:

ok 99543 numbers

Subtask #4:

score: 38
Accepted

Test #26:

score: 38
Accepted
time: 200ms
memory: 36748kb

input:

708 706 99278
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-...

output:

224362
474032
258279
143455
172286
174099
75471
441687
368905
487667
411932
378530
103144
373930
868...

result:

ok 99278 numbers

Test #27:

score: 0
Accepted
time: 183ms
memory: 36812kb

input:

14 35714 99013
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+...

output:

111870
3806
472342
145332
398550
78268
428522
85934
277539
63313
150293
210242
492211
211334
290981
...

result:

ok 99013 numbers

Test #28:

score: 0
Accepted
time: 198ms
memory: 36744kb

input:

589 848 99749
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-...

output:

64437
136422
312147
311097
489896
277573
146401
21043
406219
232266
183005
70000
345699
36401
413299...

result:

ok 99749 numbers

Test #29:

score: 0
Accepted
time: 204ms
memory: 36724kb

input:

390 1280 99793
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+...

output:

168376
205348
495837
293413
115376
154314
350662
431927
224667
457238
209321
460348
16185
165453
327...

result:

ok 99793 numbers

Test #30:

score: 0
Accepted
time: 187ms
memory: 36756kb

input:

31250 16 99528
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|.....|...........|.....|.......|
+.+-+.+.+-+-+-+.+...

output:

159855
456903
81210
343663
9000
130783
381053
28803
449851
331202
15565
207004
251474
291185
105990
...

result:

ok 99528 numbers

Test #31:

score: 0
Accepted
time: 187ms
memory: 36680kb

input:

1405 355 99263
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+...

output:

215296
128430
91274
176604
373716
477943
482548
35067
176758
318879
427914
397390
307926
286302
2422...

result:

ok 99263 numbers

Test #32:

score: 0
Accepted
time: 200ms
memory: 36752kb

input:

597 837 99999
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-...

output:

107175
430532
473806
392158
423939
104218
312754
179593
196782
21471
89653
192746
377290
68197
28796...

result:

ok 99999 numbers

Test #33:

score: 0
Accepted
time: 189ms
memory: 36736kb

input:

31250 16 99042
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|...|.|.....|.................|.|
+.+.+.+.+-+.+.+-+...

output:

212345
369383
31376
27426
355006
306962
229750
124162
349985
296387
52295
215302
354136
214231
43562...

result:

ok 99042 numbers

Test #34:

score: 0
Accepted
time: 191ms
memory: 36744kb

input:

1041 480 99778
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+...

output:

374371
366084
445679
79402
182627
404177
163689
430503
499473
224716
59440
95218
201107
386475
10594...

result:

ok 99778 numbers

Test #35:

score: 0
Accepted
time: 184ms
memory: 36692kb

input:

1171 426 99513
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+...

output:

161670
425422
329660
274544
133589
232265
469836
258618
235792
433858
265540
88981
286191
4781
28349...

result:

ok 99513 numbers

Extra Test:

score: 0
Extra Test Passed