A题,水题。
B题,博弈论题,找到的规律是当前数是奇数那么这个子游戏是必败的,否则必胜。那么异或一下即可。
C题,模拟题,考虑到第三个操作如果之前清空到第x条,且当前清空到第t条,如果t比x要小,那么可以忽略清空到t条的操作;另外所有元素最多入队列和出队列一次。那么总的复杂度是O(n)的。代码如下:

1 #include <stdio.h> 2 #include <algorithm> 3 #include <string.h> 4 #include <string> 5 #include <iostream> 6 #include <queue> 7 using namespace std; 8 const int N = 300000 + 5; 9 typedef long long ll; 10 11 queue<int> Q[N]; 12 int tot; 13 int vis[N]; 14 int who[N]; 15 16 int main() 17 { 18 int n,q; 19 cin >> n >> q; 20 int ans = 0; 21 int now = 0; 22 while(q--) 23 { 24 int a,b; 25 scanf("%d%d",&a,&b); 26 if(a == 1) 27 { 28 who[++tot] = b; 29 Q[b].push(tot); 30 ans ++; 31 } 32 else if(a == 2) 33 { 34 while(!Q[b].empty()) 35 { 36 int x = Q[b].front(); Q[b].pop(); 37 ans --; 38 vis[x] = 1; 39 } 40 } 41 else 42 { 43 for(int i=now+1;i<=b;i++) 44 { 45 if(vis[i]) continue; 46 int t = who[i]; 47 Q[t].pop(); 48 ans --; 49 } 50 now = max(now, b); 51 } 52 printf("%d ",ans); 53 } 54 return 0; 55 }
D题,题意蛮好理解的,但是有点繁琐。看了一下别人的博客说题目描述错误= =。难怪做的人这么少。