UOJ Logo

NOI.AC

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#179193#2830. introduce a little anarchyzhangchengyang100580ms4312kbC++11819b2023-08-03 11:48:122023-08-03 11:48:12

answer

#include<bits/stdc++.h>
using namespace std;
int n,m,a[100005],t,x;
string s;
int read(){
	int x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9'){
		if(c=='-') f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9'){
		x=x*10+c-'0';
		c=getchar();
	}
	return x*f;
}
void write(int x){
	if(x<0){
		putchar('-');
		x=-x;
	}
	if(x>9) write(x/10);
	putchar(x%10+'0');
}
queue<int> q1,q2[305];
void push(int x){
	int p=a[x];
	if(q2[p].empty()) q1.push(p);
	q2[p].push(x);
}
void pop(){
	int p=q1.front();
	write(q2[p].front());
	printf("\n");
	q2[p].pop();
	if(q2[p].empty()) q1.pop();
}
int main(){
	n=read();
	m=read();
	for(int i=0;i<n;i++) a[i]=read();
	t=read();
	for(int i=1;i<=t;i++){
		cin>>s;
		if(s=="push"){
			scanf("%d",&x);
			push(x);
		}
		else pop();
	}
	return 0;
}

详细

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

Test #1:

score: 10
Accepted
time: 2ms
memory: 3708kb

input:

10 5
3 4 0 4 0 4 4 4 1 0
18
push 4
push 5
push 2
pop
push 4
pop
push 2
push 8
push 9
pop
pop
push 4
...

output:

4
2
4
2

result:

ok 4 lines

Test #2:

score: 10
Accepted
time: 2ms
memory: 3772kb

input:

50 7
0 3 3 2 4 2 4 5 6 2 5 3 6 4 0 6 1 2 1 4 5 5 6 6 3 4 3 6 2 0 4 3 5 0 6 2 6 0 0 3 6 6 0 5 5 2 2 2...

output:

22
7
10
44
20
48
7
10

result:

ok 8 lines

Test #3:

score: 10
Accepted
time: 1ms
memory: 3756kb

input:

100 10
6 5 2 3 6 6 6 1 1 5 6 6 5 6 0 1 1 7 6 7 1 9 8 2 7 4 1 3 8 9 4 7 3 8 1 9 4 6 2 0 6 1 4 8 8 0 1...

output:

63
12
25
26
80
22
72
95
22

result:

ok 9 lines

Test #4:

score: 10
Accepted
time: 15ms
memory: 3728kb

input:

1000 100
61 0 29 71 80 11 67 41 46 47 77 7 38 46 2 17 31 97 18 61 1 44 2 60 46 74 11 9 61 88 89 77 3...

output:

340
854
913
952
918
89
946
549
748
805
583
168
217
168
491
249
370
592
61
906
66
645
463
230
323
419...

result:

ok 1000 lines

Test #5:

score: 10
Accepted
time: 18ms
memory: 3768kb

input:

5000 150
23 115 95 98 142 93 145 142 21 20 79 118 4 144 34 134 67 136 136 121 64 109 94 53 45 118 13...

output:

1509
3147
1377
2550
725
2589
4495
2319
4123
3862
3894
2180
2465
1247
3369
1920
4159
2346
252
3151
73...

result:

ok 3673 lines

Test #6:

score: 10
Accepted
time: 120ms
memory: 3868kb

input:

30000 300
268 196 285 41 83 123 252 0 89 204 139 91 182 72 9 182 41 91 232 98 133 130 232 7 194 150 ...

output:

8596
28075
6211
1553
5183
15065
26135
14967
9317
9062
29902
25180
27873
6514
11211
6408
29289
14566
...

result:

ok 35000 lines

Test #7:

score: 10
Accepted
time: 54ms
memory: 3996kb

input:

50000 250
217 103 35 135 39 134 233 86 145 172 56 79 14 215 25 51 60 187 32 224 204 194 181 208 194 ...

output:

18240
26001
13883
24324
37472
32543
2598
10513
2271
5072
43541
32648
34582
49166
38248
34316
21845
2...

result:

ok 9974 lines

Test #8:

score: 10
Accepted
time: 126ms
memory: 4192kb

input:

75000 275
126 61 14 119 74 146 224 157 61 240 172 156 189 120 30 84 26 260 72 243 236 52 21 269 142 ...

output:

41894
30738
60313
22058
25736
49937
9083
69830
56554
9301
15107
71751
5650
69263
60358
37482
9698
56...

result:

ok 14993 lines

Test #9:

score: 10
Accepted
time: 119ms
memory: 4284kb

input:

100000 300
91 293 27 173 140 98 8 213 255 57 218 197 177 74 285 87 7 5 132 156 67 98 257 200 256 188...

output:

3935
88406
20424
83303
93438
26197
97018
31654
63785
27911
73836
49039
34640
1270
93348
41963
77556
...

result:

ok 19920 lines

Test #10:

score: 10
Accepted
time: 123ms
memory: 4312kb

input:

100000 300
123 221 288 7 120 202 8 116 238 114 299 23 88 39 180 168 188 295 184 229 254 297 171 57 1...

output:

90039
64927
74392
16333
11945
90851
65681
88227
25613
91726
12221
74216
31597
69885
22093
76589
8497...

result:

ok 20123 lines