ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#160660 | #2830. introduce a little anarchy | LNY | 100 | 152ms | 2380kb | C++11 | 1.3kb | 2022-10-04 10:38:49 | 2022-10-04 12:04:58 |
answer
#include<bits/stdc++.h>
#ifndef ONLINE_JUDGE
#include "debug.cpp"
#endif
using namespace std;
struct node{int data;int xb;};
vector<vector<node> > q;
char s[5];
int a[100005];
int main()
{
int n,m;
scanf("%d%d",&n,&m);
//q.push_back({});
for(int i=0;i<n;i++){
int x;
scanf("%d",&x);
a[i]=x;
}
//-------------------------------------------------------------
int j=0;
int T;
scanf("%d",&T);getchar();
for(int i=0;i<T;i++)
{
//printf("%d\n",i);
scanf("%s",s);
//getchar();
//printf("%s\n",s/*,s=="pop\0"*/);
if(!strcmp(s,"pop"))
{
printf("%d\n",q[j].front().xb);
q[j].erase(q[j].begin());
//q[j].pop_back();
if(q[j].size()==0)
j++;
//PrintV(q[0].begin(),q[0].end());
}
else{
bool flag=false;
int t;
scanf("%d",&t);
//getchar();
//printf("%d\n",t);
int len=q.size();
//printf("%d\n",len);
for(int p=j;p<len;p++){
//printf("\t%d\n",p);
if(q[p][0].data==a[t]){
flag=true;
q[p].push_back({a[t],t});
break;
}
}
//getchar();getchar();getchar();getchar();getchar();getchar();
if(!flag){
q.push_back({});
q.back().push_back({a[t],t});
}
}
//for(int p=j;p<q.size();p++)
// PrintV(q[p].begin(),q[p].end());
}
return 0;
}
详细
小提示:点击横条可展开更详细的信息
Test #1:
score: 10
Accepted
time: 0ms
memory: 1252kb
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: 1256kb
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: 1256kb
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: 1288kb
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: 4ms
memory: 1376kb
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: 30ms
memory: 1596kb
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: 18ms
memory: 1956kb
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: 27ms
memory: 2116kb
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: 37ms
memory: 2380kb
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: 36ms
memory: 2380kb
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