10月8日翻车实录

T1:……

自己在那里口胡来口胡去也没口胡出来……

正解就是个队列+贪心啊啊啊啊啊啊啊啊啊……

 1 #pragma GCC optimize("O3")
 2 #include <iostream>
 3 #include <cstdio>
 4 #include <cstring>
 5 #include <algorithm>
 6 #include <set>
 7 using namespace std;
 8 set<int>s;
 9 const int maxn=(int)1e6+5;
10 int a[maxn],n,m,d,L;
11 void Fastread(int &x)
12 {
13     x=0;char c=getchar();
14     while(c<'0'||c>'9')c=getchar();
15     while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();
16 }
17 int haha()
18 {
19     int t;scanf("%d",&t);
20     while(t--)
21     {
22         Fastread(n),Fastread(m),Fastread(d),Fastread(L);s.clear();s.insert(L);s.insert(0);
23         for(int i=1;i<=n;i++)Fastread(a[i]),s.insert(a[i]);
24         int num=0;
25         for(int i=1;i<=m;i++)
26         {
27             int now=0;set<int>::iterator it;
28             while(now<L)
29             {
30                 it=s.upper_bound(now+d);--it;
31                 if((*it)<=now)break;
32                 now=(*it);
33                 if((*it)!=L)s.erase(it);
34             }
35             if(now==L)num++;else break;
36         }
37         if(num==m)puts("Excited");
38         else printf("%d
",num);
39     }
40 }
41 int sb=haha();
42 int main(){;}
A

T2:唯一值得写的东西……

这个东西其实和之前那个题有相似之处……就是那个Treap上LCA……那个东西维护了三个量……向左最长上升序列……向右最长上升序列……最大值……这个题呢……也是维护三个东西……一个砍掉多少……一个插上多少……一个插完后的总和……更新父节点时需要极其小心……因为根据砍掉多少问题分为三种情况:右边不砍,左边够砍,左边不够砍……具体看代码……

 1 #include <bits/stdc++.h>
 2 using namespace std;
 3 const int maxn=200005;
 4 int Cutdown[maxn<<2],Addup[maxn<<2],Sum[maxn<<2];
 5 void Fastread(int &x)
 6 {
 7     x=0;char c=getchar();
 8     while(c<'0'||c>'9')c=getchar();
 9     while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();
10 }
11 #define mid ((l+r)>>1)
12 #define lc root<<1
13 #define rc root<<1|1
14 #define lson lc,l,mid
15 #define rson rc,mid+1,r
16 int m,q;
17 int opt[maxn],num[maxn];
18 int Query(int root,int val)
19 {
20     if(val==Addup[rc])return Sum[root]-Sum[rc];
21     else if(val<Addup[rc])return Sum[root]-Sum[rc]+Query(rc,val);
22     else return Query(lc,val-Addup[rc]+Cutdown[rc]);
23 }
24 void Pushup(int root)
25 {
26     if(Cutdown[rc]>=Addup[lc])
27         Cutdown[root]=Cutdown[lc]+Cutdown[rc]-Addup[lc],
28         Addup[root]=Addup[rc],
29         Sum[root]=Sum[rc];
30     else if(!Cutdown[rc])
31         Addup[root]=Addup[lc]+Addup[rc],
32         Sum[root]=Sum[lc]+Sum[rc],
33         Cutdown[root]=Cutdown[lc];
34     else Cutdown[root]=Cutdown[lc],
35         Addup[root]=Addup[lc]+Addup[rc]-Cutdown[rc],
36         Sum[root]=Sum[rc]+Query(lc,Cutdown[rc]);
37 }
38 void Modify(int root,int l,int r,int pos)
39 {
40     if(l==r)
41     {
42         Addup[root]=Cutdown[root]=Sum[root]=0;
43         int x;Fastread(x);
44         if(x)Fastread(Cutdown[root]);
45         else Fastread(Sum[root]),Addup[root]=1;
46         return ;
47     }
48     if(pos<=mid)Modify(lson,pos);else if(pos>mid)Modify(rson,pos);
49     Pushup(root);
50 }
51 void Build(int root,int l,int r)
52 {
53     if(l==r)
54     {
55         if(opt[l])Cutdown[root]=num[l];
56         else Addup[root]=1,Sum[root]=num[l];
57         return ;
58     }
59     Build(lson);Build(rson);Pushup(root);
60 }
61 int haha()
62 {
63     Fastread(m),Fastread(q);
64     for(int i=1;i<=m;i++)Fastread(opt[i]),Fastread(num[i]);
65     Build(1,1,m);
66     while(q--)
67     {
68         int pos;Fastread(pos);
69         Modify(1,1,m,pos);
70         printf("%d
",Sum[1]);
71     }
72 }
73 int sb=haha();
74 int main(){;}
B

T3:我还能写点啥啊(请自觉脑补东北(?)口音我也不知道我那个口音是哪里来的)辣鸡出题人写错数据范围吃枣药丸……

我们需要一个智障十字链表……维护来维护去……不断修改方向,注意修改顺序……啊麻烦死了……卡(强)一(开)波(O)常(3)交暴力吧……纳尼$A$了?!……有句$mmp$必须要讲……

 1 #pragma GCC optimize("O3")
 2 #include <iostream>
 3 #include <cstdio>
 4 #include <cstring>
 5 #include <algorithm>
 6 using namespace std;
 7 const int maxn=2005;
 8 char map[maxn][maxn],backup[maxn][maxn];int n,m,q;
 9 void Fastread(int &x)
10 {
11     x=0;char c=getchar();
12     while(c<'0'||c>'9')c=getchar();
13     while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();
14 }
15 void Fastread(char &x)
16 {
17     x=0;char c=getchar();
18     while(c<'0'||c>'9')c=getchar();
19     x=c;
20 }
21 int haha()
22 {
23     Fastread(n),Fastread(m),Fastread(q);
24     for(int i=1;i<=n;i++)
25         for(int j=1;j<=m;j++)Fastread(map[i][j]);
26     while(q--)
27     {
28         int x,y,z;Fastread(x),Fastread(y),Fastread(z);
29         for(int i=0;i<z;i++)
30             for(int j=0;j<z;j++)backup[j][z-1-i]=map[x+i][y+j];
31         for(int i=0;i<z;i++)
32             for(int j=0;j<z;j++)map[x+i][y+j]=backup[i][j];
33     }
34     for(int i=1;i<=n;i++)
35     {
36         for(int j=1;j<=m;j++)printf("%c ",map[i][j]);
37         puts("");
38     }
39 }
40 int sb=haha();
41 int main(){;}
C的窒息操作
原文地址:https://www.cnblogs.com/Loser-of-Life/p/7643143.html