-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1607.cpp
More file actions
executable file
·67 lines (63 loc) · 1.51 KB
/
Copy path1607.cpp
File metadata and controls
executable file
·67 lines (63 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/**
* 全wa了
* 不写了
* 题意理解错了属实拉跨
**/
#include <iostream>
#include <stdio.h>
#define re register
using namespace std;
inline void read(int &x) {
x = 0;
char ch;
bool f = 0;
while (ch = getchar(), (ch < '0' || ch > '9') && ch != '-');
if (ch == '-') f = 1;
else x = ch - '0';
while(ch = getchar(), ch >= '0' && ch <= '9') x = 10 * x + ch - '0';
x = f ? -x : x;
}
int p[2000233], n, query, op, idq[2000233], numq[2000233], rear, pnum, head, qcur;
// int p[200], n, query, op, idq[200], numq[200], idnum, pnum, head, qcur;
inline int find(const int &x) {
for(re int i = head;i < rear;++ i) {
if(idq[i] == x) return i;
}
return -1;
}
int main() {
read(n);
for(re int i = 0;i < n;++ i) {
read(p[i]);
}
read(query);
for(int i = 0;i < query;++ i) {
read(op);
if(!op) {
if(pnum == n) continue;
else {
int tmp = find(p[pnum]);
++ qcur;
if(tmp == -1) {
++ numq[rear];
idq[rear ++] = p[pnum ++];
} else {
++ pnum;
++ numq[tmp];
}
}
} else {
if(qcur) {
printf("%d\n", idq[head]);
-- qcur;
-- numq[head];
if(!numq[head]) {
++ head;
}
} else {
printf("%d\n", -1);
}
}
}
return 0;
}