UOJ Logo

NOI.AC

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#160508#2830. introduce a little anarchycrazy_cloud100311ms2052kbC++11750b2022-10-03 18:39:572022-10-03 18:39:59

answer

#include<iostream>
#include<cstring>
#include<string>
#include<cstdio>
#include<queue>
#define N 100005
#define M 305
using namespace std;

int n,m,k;
queue<int>que[M];
queue<int>q;
int belong[N];

int main(){
    scanf("%d%d",&n,&m);
    for(int i=0;i<n;++i)
        scanf("%d",&belong[i]);
    scanf("%d",&k);
    string str;
    while(k--){
        cin>>str;
        if(str=="push"){
            scanf("%d",&n);
            if(!que[belong[n]].size())q.push(belong[n]);
            que[belong[n]].push(n);
        }
        else {
            int temp=q.front();
            printf("%d\n",que[temp].front());
            que[temp].pop();
            if(que[temp].empty())q.pop();
        }
    }
    return 0;
}

详细

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

Test #1:

score: 10
Accepted
time: 0ms
memory: 1496kb

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: 0ms
memory: 1500kb

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: 0ms
memory: 1500kb

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: 0ms
memory: 1480kb

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: 10ms
memory: 1532kb

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: 54ms
memory: 1572kb

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: 48ms
memory: 1776kb

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: 47ms
memory: 1772kb

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: 68ms
memory: 2036kb

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: 84ms
memory: 2052kb

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