海亮日寄2.0
day -inf
回大连再写
算了,开写
听说期末考试不补考了,于是停课在410写bytoj
笑死,停课一周写了bytoj的1/4
一大早六点半从家里出发去赶飞机,顺便在机场吃了早饭
大家都没来,东方幻想eclipse启动!需要更新???pubg启动!账号寄了??
我***************************************************************************************************
很好,飞机晚点半小时,于是在机场傻站着
终于到了hl,没有收手机,于是开新号玩游戏,爽!
day1 6.27 构造题专练
[正睿集训2021] 构造专练 - C202044zxy - 博客园 (cnblogs.com)
原题都在这里了
t1

1 #include<bits/stdc++.h> 2 using namespace std; 3 int main() 4 { 5 int n; 6 cin>>n; 7 if(n%2==0) 8 { 9 cout<<"NO"<<endl; 10 return 0; 11 } 12 cout<<"YES"<<endl; 13 for(int i=0;i<n;i++) 14 { 15 cout<<i<<endl; 16 } 17 for(int i=0;i<n;i++) 18 { 19 cout<<i<<endl; 20 } 21 for(int i=0;i<n;i++) 22 { 23 cout<<2*i%n<<endl; 24 } 25 return 0; 26 }
t2

1 #include<bits/stdc++.h> 2 using namespace std; 3 int main() 4 { 5 int n; 6 cin>>n; 7 n=pow(2,n)-1; 8 int sum=n*(n-1)/6; 9 cout<<sum<<endl; 10 for(int i=1;i<=n;i++) 11 { 12 for(int j=1+i;j<=n;j++) 13 { 14 int k=0 xor i xor j; 15 if(k>j) 16 { 17 cout<<k<<" "<<i<<" "<<j<<endl; 18 } 19 } 20 } 21 return 0; 22 }
t3 最恶心的一集

1 #include<bits/stdc++.h> 2 using namespace std; 3 vector<pair<int,int>>q[11451]; 4 int n; 5 int main() 6 { 7 cin>>n; 8 for(int i=0;i<2*n-1;i++) 9 { 10 for(int j=i+1;j<2*n-1;j++) 11 { 12 q[(i+j)%(2*n-1)].push_back(make_pair(i,j)); 13 } 14 } 15 for(int i=0;i<2*n-1;i++) 16 { 17 q[2*i%(2*n-1)].push_back(make_pair(i,2*n-1)); 18 } 19 for(int i=0;i<2*n-1;i++) 20 { 21 for(auto ans:q[i]) 22 { 23 cout<<ans.first+1<<" "<<ans.second+1<<endl; 24 } 25 } 26 return 0; 27 }
注意上述代码不开o2过不了
t4

1 #include<bits/stdc++.h> 2 using namespace std; 3 const int maxn = 2020; 4 int per[maxn],st[maxn],top; 5 int n; 6 std::set<int> s[maxn]; 7 inline int adde(int x,int y){ 8 if(s[x].count(y)||s[y].count(x))return 1; 9 s[x].insert(y),s[y].insert(x); 10 return 0; 11 } 12 char buf[(int)1e8],*vout=buf; 13 inline void pc(int x){*vout++=x;} 14 inline void put(int x){ 15 if(x>9)put(x/10); 16 pc(x%10+48); 17 } 18 int main(){ 19 scanf("%d",&n); 20 put(n/2),pc(10); 21 for(int i=1;i<=n;i+=2)per[i]=++top; 22 top=n; 23 for(int i=2;i<=n;i+=2)per[i]=top--; 24 for(int i=1;i<=n/2;++i){ 25 for(int j=1;j<n;++j){ 26 put(per[j]),pc(' '),put(per[j+1]),pc(' '); 27 } 28 for(int i=1;i<=n;++i)++per[i]==n+1?per[i]=1:0; 29 pc(10); 30 } 31 fwrite(buf,vout-buf,1,stdout); 32 }
不知道为啥,hloj没法交cf的题,索性交洛谷
_________________________________________________________可爱的分割线_______________________________________________________________________________________
连自己想+看题解+问别人终于写了十道题,1k pts
来之前我洛谷只AC了7道紫题
今天一晚上写了4紫+1黑
由于紫题之前做过一些,所以索性说一下那个黑题
传送门:Rectangular Polyline - 洛谷 | 计算机科学教育新生态 (luogu.com.cn)
其实这道题好像数学上向量的基底分解
只需要用背包维护存在|𝑎𝑖|=𝑙𝑖,|𝑏𝑖|=𝑝𝑖且∑ai=∑bi=0,其中i∈[1,n]
woc,快九点了
直接上代码

1 #include<bits/stdc++.h> 2 using namespace std; 3 const int maxn = 1005; 4 bitset<maxn*maxn>f[maxn]; 5 int t,n,m,a[maxn],b[maxn]; 6 inline cal(int *a) 7 { 8 int m=0; 9 for(int i=1;i<=n;i++) 10 { 11 m+=a[i]; 12 } 13 if(m&1) 14 { 15 return 0; 16 } 17 m>>=1; 18 for(int i=1;i<=n;i++) 19 { 20 f[i]=((f[i-1])|(f[i-1]<<a[i])); 21 } 22 if(!f[n][m]) 23 { 24 return 0; 25 } 26 for(int i=n;i;i--) 27 { 28 if(!f[i-1][m]) 29 { 30 m-=a[i]; 31 a[i]=-a[i]; 32 } 33 } 34 return 1; 35 } 36 int main() 37 { 38 f[0][0]=1; 39 cin>>t; 40 while(t--) 41 { 42 cin>>n; 43 for(int i=1;i<=n;i++) 44 { 45 cin>>a[i]; 46 } 47 cin>>m; 48 for(int i=1;i<=m;i++) 49 { 50 cin>>b[i]; 51 } 52 if((n!=m) or (!cal(a)) or (!cal(b))) 53 { 54 cout<<"NO"<<endl; 55 continue; 56 } 57 int cnt=0; 58 for(int i=1;i<=n;i++) 59 { 60 cnt+=(a[i]<0)-(b[i]<0); 61 } 62 if(cnt<0) 63 { 64 for(int i=1;i<=n;i++) 65 { 66 a[i]=-a[i]; 67 b[i]=-b[i]; 68 } 69 } 70 sort(a+1,a+1+n),reverse(a+1,a+1+n); 71 sort(b+1,b+1+n),reverse(b+1,b+1+n); 72 for(int i=1;i<=n+1;i++) 73 { 74 if((i>n) or (a[i]<0)) 75 { 76 reverse(b+1,b+i); 77 break; 78 } 79 } 80 for(int i=n;i>=0;i--) 81 { 82 if((!i) or (b[i]>0)) 83 { 84 reverse(a+i+1,a+1+n); 85 break; 86 } 87 } 88 cout<<"YES"<<endl; 89 for(int i=1,x=0,y=0;i<=n;i++) 90 { 91 x+=a[i]; 92 cout<<x<<" "<<y<<endl; 93 y+=b[i]; 94 cout<<x<<" "<<y<<endl; 95 } 96 } 97 return 0; 98 }
day2 6.28
上午模拟赛,全是remote judge题,结果codeforces崩了(估计现在毛子们在睡觉,服务器下线维护了)
前两题煞笔题目,20分钟拿下
t3,好像可以参照转换二进制写法,对k取模之后进行计算(k进制数最大为k--),但是注意要有qpow,否则日爆

1 #include<bits/stdc++.h> 2 using namespace std; 3 const int maxn = 114; 4 const int inf = 1e6; 5 typedef long long ll; 6 ll t,n,k,cnt,a[maxn],vis[maxn],fac[maxn]; 7 int main() 8 { 9 cin>>t; 10 while(t--) 11 { 12 memset(vis,0,sizeof(vis)); 13 cin>>n>>k; 14 fac[0]=1; 15 for(int i=1;fac[i-1]<inf;i++) 16 { 17 fac[i]=fac[i-1]*k; 18 cnt=i; 19 } 20 for(int i=1;i<=n;i++) 21 { 22 cin>>a[i]; 23 } 24 for(int i=1;i<=n;i++) 25 { 26 int p=0; 27 while(a[i]) 28 { 29 vis[p]+=a[i]%k; 30 a[i]/=k; 31 p++; 32 } 33 } 34 bool flag=false; 35 for(int i=0;i<=cnt;i++) 36 { 37 if(vis[i]>1) 38 { 39 flag=true; 40 } 41 } 42 if(flag) 43 { 44 cout<<"NO"<<endl; 45 } 46 else 47 { 48 cout<<"YES"<<endl; 49 } 50 } 51 return 0; 52 }
t4
智商正常的应该都能看出来相等的一组数肯定在最大值的两边,那么可以将除了最大值外的所有数分在最大值的两边
然而至少有三个数才可以进行上述操作,加个特判就完事了

1 #include<bits/stdc++.h> 2 using namespace std; 3 typedef long long ll; 4 const ll mod = 998244353; 5 inline ll read() 6 { 7 int x=0,f=1; 8 char ch=getchar(); 9 while(ch<'0'||ch>'9') 10 { 11 if(ch=='-') 12 f=-1; 13 ch=getchar(); 14 } 15 while(ch>='0' && ch<='9') 16 x=x*10+ch-'0',ch=getchar(); 17 return x*f; 18 } 19 inline ll ksm(ll a,ll b) 20 { 21 ll res=1; 22 while(b) 23 { 24 if(b&1) 25 { 26 res=res*a%mod; 27 } 28 a=a*a%mod; 29 b>>=1; 30 } 31 return res; 32 } 33 ll ans=1,res=1; 34 int main() 35 { 36 int n=read(),m=read(); 37 if(n==2) 38 { 39 cout<<0<<endl; 40 return 0; 41 } 42 for(int i=1;i<=m;i++) 43 { 44 ans=ans*i%mod; 45 } 46 for(int i=1;i<=n-1;i++) 47 { 48 res=res*i%mod; 49 } 50 for(int i=1;i<=m-n+1;i++) 51 { 52 res=res*i%mod; 53 } 54 ans=((ans*ksm(res,mod-2)%mod)*(n-2)%mod)*ksm(2,n-3)%mod; 55 cout<<ans<<endl; 56 return 0; 57 }
t5
区间dp大水题
只需要找到[l,r]长度和区间和的特殊情况,就可以结束了

1 #include<bits/stdc++.h> 2 using namespace std; 3 const int maxn = 505; 4 int a[maxn],n,dp[maxn][maxn]; 5 int sum[maxn][maxn]; 6 //sum qujianhe 7 //dp qujianchangdu min 8 int main() 9 { 10 memset(dp,1e6,sizeof(dp)); 11 cin>>n; 12 for(int i=1;i<=n;i++) 13 { 14 cin>>a[i]; 15 dp[i][i]=1; 16 sum[i][i]=a[i]; 17 } 18 for(int k=2;k<=n;k++) 19 { 20 for(int l=1;l+k-1<=n;l++) 21 { 22 int r=l+k-1; 23 for(int mid=l;mid<r;mid++) 24 { 25 dp[l][r]=min(dp[l][r],dp[l][mid]+dp[mid+1][r]); 26 if(sum[l][mid]==sum[mid+1][r] and dp[l][mid]==1 and dp[l][mid]==dp[mid+1][r]) 27 { 28 dp[l][r]=1; 29 sum[l][r]=sum[l][mid]+1; 30 } 31 } 32 } 33 } 34 cout<<dp[1][n]<<endl; 35 return 0; 36 }
t5写完就剩10分钟了,索性开摆
就是说今天cf怎么推出oi赛制了
中午回寝室,累的厉害,于是躺在床上探讨哲学问题和恋爱心理
就是说hl的床,上铺翻身的时候下面跟坐船一样,晃得厉害,俗称《有推背感》
day3 6.29
说在前面,考试前不要眼瞎,看清楚是标准输入输出还是文件读写,这个神操作导致我33pts-—>0pts
警钟撅烂
题目挺难,考完瞬间想退役了
但是听完讲解感觉自己又行了(“很难不想到”)
不细说了,离谱
day4 6.30
上午团建,累死,下午回寝室玩到4点半。
听说要学平衡树了,于是预习,还有亲手调了一个小时才写完的splay板子,直到发现把-inf写成了inf,自己脑补精神状态

#include<bits/stdc++.h> #define root tree[0].ch[1] #define inf 1000000005 using namespace std; inline int read() { register int x=0,f=1;register char ch=getchar(); while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();} while(ch>='0'&&ch<='9')x=(x<<3)+(x<<1)+ch-'0',ch=getchar(); return x*f; } struct Splay{ int fa,ch[2],v,sum,rec; }tree[50005]; int tot=0; inline bool findd(register int x) { return x==tree[tree[x].fa].ch[0]?0:1; } inline void connect(register int x,register int fa,register int son) { tree[x].fa=fa; tree[fa].ch[son]=x; } inline void update(register int x) { tree[x].sum=tree[tree[x].ch[0]].sum+tree[tree[x].ch[1]].sum+tree[x].rec; } inline void rotate(register int x) { int Y=tree[x].fa; int R=tree[Y].fa; int Yson=findd(x); int Rson=findd(Y); int B=tree[x].ch[Yson^1]; connect(B,Y,Yson); connect(Y,x,Yson^1); connect(x,R,Rson); update(Y),update(x); } inline void splay(register int x,register int to) { to=tree[to].fa; while(tree[x].fa!=to) { int y=tree[x].fa; if(tree[y].fa==to) rotate(x); else if(findd(x)==findd(y)) rotate(y),rotate(x); else rotate(x),rotate(x); } } inline int newpoint(register int v,register int fa) { tree[++tot].v=v; tree[tot].fa=fa; tree[tot].sum=tree[tot].rec=1; return tot; } inline void Insert(register int x) { int now=root; if(root==0) { newpoint(x,0); root=tot; } else { while(1) { ++tree[now].sum; if(x==tree[now].v) { ++tree[now].rec; splay(now,root); return; } int nxt=x<tree[now].v?0:1; if(!tree[now].ch[nxt]) { int p=newpoint(x,now); tree[now].ch[nxt]=p; splay(p,root); return; } now=tree[now].ch[nxt]; } } } inline int find(register int x) { int now=root; while(1) { if(x==tree[now].v) { splay(now,root); return now; } int nxt=x<tree[now].v?0:1; if(!tree[now].ch[nxt]) return 0; now=tree[now].ch[nxt]; } } inline void delet(register int x) { int pos=find(x); if(!pos) return; if(tree[pos].rec>1) { --tree[pos].rec; --tree[pos].sum; } else { if(!tree[pos].ch[0]&&!tree[pos].ch[1]) root=0; else if(!tree[pos].ch[0]) { root=tree[pos].ch[1]; tree[root].fa=0; } else { int left=tree[pos].ch[0]; while(tree[left].ch[1]) left=tree[left].ch[1]; splay(left,tree[pos].ch[0]); connect(tree[pos].ch[1],left,1); connect(left,0,1); update(left); } } } inline int lower(register int v) { int now=root,ans=-inf; while(now) { if(tree[now].v<v&&tree[now].v>ans) ans=tree[now].v; if(tree[now].v>v) now=tree[now].ch[0]; else now=tree[now].ch[1]; } return ans; } inline int upper(register int v) { int now=root,ans=inf; while(now) { if(tree[now].v>v&&tree[now].v<ans) ans=tree[now].v; if(tree[now].v>v) now=tree[now].ch[0]; else now=tree[now].ch[1]; } return ans; } bool vis[50005]; int stac[50005],top=-1; int main() { memset(vis,false,sizeof(vis)); int n=read(),m=read(); Insert(0); Insert(n+1); while(m--) { char ch=getchar(); while(ch!='D'&&ch!='R'&&ch!='Q') ch=getchar(); if(ch=='D') { int x=read(); vis[x]=true; stac[++top]=x; Insert(x); } else if(ch=='R') { vis[stac[top]]=false; delet(stac[top--]); } else { int x=read(); if(vis[x]) puts("0"); else { cout<<(upper(x)-lower(x)-1)<<endl; } } } return 0; }
day5 7.1
rfy限时返场讲课,平衡树?!
听FDsama等已经肝过金牌导航的神犇们说平衡树极其的简单
听完后我的评价是
简单个**
引用一下化竞大佬zyw的名言:“退竞!!!!!!!!!!!!!!!!!!!!”
我也是终于明白一道题写两个小时200 lines+结果写挂了是什么感觉了
但是有一说一,为什么rfy给的题好像没有一道题必须用平衡树?
A.luogu p3165

#include<bits/stdc++.h> using namespace std; const int maxn = 1e5+5; struct node { int i,k; }a[maxn]; inline int read() { register int x=0,f=1;register char ch=getchar(); while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();} while(ch>='0'&&ch<='9')x=(x<<3)+(x<<1)+ch-'0',ch=getchar(); return x*f; } int n,fa[maxn],siz[maxn],ch[maxn][2],root,tag[maxn]; inline bool cmp(node a,node b) { if(a.k<b.k) { return 1; } if(a.k==b.k) { return a.i<b.i; } return 0; } inline void update(int x) { siz[x]=siz[ch[x][0]]+siz[ch[x][1]]+1; } inline void build(int l,int r,int f) { if(l>r) { return; } int mid=(l+r)>>1; if(mid<f) { ch[f][0]=mid; } else ch[f][1]=mid; siz[mid]=1; fa[mid]=f; if(l==r) { return; } build(l,mid-1,mid); build(mid+1,r,mid); update(mid); } inline void down(int k) { tag[k]^=1; if(ch[k][0]) { tag[ch[k][0]]^=1; } if(ch[k][1]) { tag[ch[k][1]]^=1; } swap(ch[k][1],ch[k][0]); } inline void roate(int x,int &goal) { int y=fa[x],z=fa[y],k=ch[y][1]==x; if(y==goal) { goal=x; } else { ch[z][ch[z][1]==y]=x; } ch[y][k]=ch[x][k^1]; ch[x][k^1]=y; fa[y]=x; fa[x]=z; fa[ch[y][k]]=y; update(y); } inline void splay(int x,int &goal) { while(x!=goal) { int y=fa[x],z=fa[y]; if(tag[z]) { down(z); } if(tag[y]) { down(y); } if(tag[x]) { down(x); } if(y!=goal) { if(ch[y][1]==x^ch[z][1]==y) { roate(x,goal); } else { roate(y,goal); } } roate(x,goal); update(x); } } inline int find(int now,int k) { if(tag[now]) { down(now); } int l=ch[now][0],r=ch[now][1]; if(siz[l]+1==k) { return now; } if(k<=siz[l]) { return find(l,k); } return find(r,k-siz[l]-1); } inline void reverse(int l,int r) { int x=find(root,l-1),y=find(root,r+1); splay(x,root); splay(y,ch[x][1]); tag[ch[y][0]]^=1; } int main() { n=read(); for(int i=1;i<=n;i++) { a[i+1].k=read(); a[i+1].i=i+1; } a[1].i=1; a[n+2].i=n+2; a[n+2].k=2000000001; sort(a+1,a+3+n,cmp); build(1,n+2,0); root=n+3>>1; int p; for(int i=2;i<=n;i++) { splay(a[i].i,root); p=siz[ch[root][0]]+1; cout<<p-1<<" "; reverse(i,p); } cout<<n<<endl; return 0; }
B.cf702f treap树板子题(代码有亮点)

1 #include<bits/stdc++.h> 2 using namespace std; 3 #define ls(x) tr[x].l 4 #define rs(x) tr[x].r 5 inline int read() 6 { 7 int x=0,f=1;char ch=getchar(); 8 while(ch<'0'||ch>'9'){ 9 if(ch=='-') 10 f=-1; 11 ch=getchar(); 12 } 13 while(ch>='0'&&ch<='9') 14 x=(x<<3)+(x<<1)+ch-'0',ch=getchar(); 15 return x*f; 16 } 17 const int maxn = 2e5+5; 18 struct treap 19 { 20 int siz,val,sum,w; 21 int l,r; 22 int lazy,sub; 23 }tr[maxn]; 24 int root,cnt,a,b,c; 25 inline int add(int k) 26 { 27 tr[++cnt].val=k; 28 tr[cnt].w=rand(); 29 tr[cnt].siz=1; 30 tr[cnt].l=tr[cnt].r=tr[cnt].sum=tr[cnt].lazy=tr[cnt].sub=0; 31 return cnt; 32 } 33 inline void pushup(int x) 34 { 35 tr[x].siz=tr[ls(x)].siz+tr[rs(x)].siz+1; 36 } 37 inline void pushdown(int x) 38 { 39 if(tr[x].lazy) 40 { 41 if(ls(x)) 42 { 43 tr[ls(x)].lazy+=tr[x].lazy; 44 tr[ls(x)].sum+=tr[x].lazy; 45 } 46 if(rs(x)) 47 { 48 tr[rs(x)].lazy+=tr[x].lazy; 49 tr[rs(x)].sum+=tr[x].lazy; 50 } 51 tr[x].lazy=0; 52 } 53 if(tr[x].sub) 54 { 55 if(ls(x)) 56 { 57 tr[ls(x)].sub+=tr[x].sub; 58 tr[ls(x)].val-=tr[x].sub; 59 } 60 if(rs(x)) 61 { 62 tr[rs(x)].sub+=tr[x].sub; 63 tr[rs(x)].val-=tr[x].sub; 64 } 65 tr[x].sub=0; 66 } 67 } 68 inline void splitval(int x,int k,int &a,int &b) 69 { 70 if(!x) 71 { 72 return a=b=0,void(); 73 } 74 pushdown(x); 75 if(k>=tr[x].val) 76 { 77 a=x; 78 splitval(rs(x),k,rs(x),b); 79 } 80 else 81 { 82 b=x; 83 splitval(ls(x),k,a,ls(x)); 84 } 85 pushup(x); 86 } 87 inline void splitsiz(int x,int k,int &a,int &b) 88 { 89 if(!x) 90 { 91 return a=b=0,void(); 92 } 93 pushdown(x); 94 if(k>=tr[ls(x)].siz+1) 95 { 96 a=x; 97 splitsiz(rs(x),k-tr[ls(x)].siz-1,rs(x),b); 98 } 99 else 100 { 101 b=x; 102 splitsiz(ls(x),k,a,ls(x)); 103 } 104 pushup(x); 105 } 106 inline int merge(int x,int y) 107 { 108 if(!x or !y) 109 { 110 return x|y; 111 } 112 pushdown(x); 113 pushup(x); 114 pushdown(y); 115 pushup(y); 116 if(tr[x].w<tr[y].w) 117 { 118 rs(x)=merge(rs(x),y); 119 return pushup(x),x; 120 } 121 else 122 { 123 ls(y)=merge(x,ls(y)); 124 return pushup(y),y; 125 } 126 } 127 inline void ins(int k) 128 { 129 int a,b; 130 splitval(root,k,a,b); 131 root=merge(merge(a,add(k)),b); 132 } 133 inline void update(int x) 134 { 135 if(!x) 136 { 137 return; 138 } 139 pushdown(x); 140 update(ls(x)); 141 update(rs(x)); 142 } 143 /****************************** 144 treap-tree juejueviki617 145 ******************************/ 146 147 int n,m; 148 struct node 149 { 150 int c,q; 151 bool operator<(const node &b) const 152 { 153 if(q!=b.q) 154 { 155 return q>b.q; 156 } 157 else 158 { 159 return c<b.c; 160 } 161 } 162 }p[maxn]; 163 int v[maxn]; 164 queue<int> q; 165 inline void build(int &r1,int r2,int x) 166 { 167 int a,b; 168 while(!q.empty()) 169 { 170 q.pop(); 171 } 172 q.push(r2); 173 while(!q.empty()) 174 { 175 int tmp=q.front(); 176 q.pop(); 177 pushdown(tmp); 178 if(ls(tmp)) 179 { 180 q.push(ls(tmp)); 181 } 182 if(rs(tmp)) 183 { 184 q.push(rs(tmp)); 185 } 186 splitval(r1,tr[tmp].val-p[x].c,a,b); 187 ls(tmp)=rs(tmp)=tr[tmp].lazy=tr[tmp].sub=0; 188 tr[tmp].val-=p[x].c; 189 tr[tmp].siz=1; 190 tr[tmp].sum++; 191 r1=merge(merge(a,tmp),b); 192 } 193 } 194 inline void work(int x) 195 { 196 int a,b,c; 197 splitval(root,p[x].c-1,a,b); 198 splitval(b,(p[x].c<<1)-1,b,c); 199 tr[c].sub+=p[x].c; 200 tr[c].val-=p[x].c; 201 tr[c].sum++; 202 tr[c].lazy++; 203 build(a,b,x); 204 root=merge(a,c); 205 } 206 int main() 207 { 208 n=read(); 209 for(int i=1;i<=n;i++) 210 { 211 p[i].c=read(); 212 p[i].q=read(); 213 } 214 sort(p+1,p+1+n); 215 m=read(); 216 for(int i=1;i<=m;i++) 217 { 218 int x=read(); 219 ins(x); 220 } 221 for(int i=1;i<=n;i++) 222 { 223 work(i); 224 } 225 update(root); 226 for(int i=1;i<=m;i++) 227 { 228 cout<<tr[i].sum<<" "; 229 } 230 return 0; 231 }
后续不写了,因为t6我没写,其他的因为被平衡树折磨地索性不用了qwq
/*
在这里特别说几句,部分人学竞赛成绩还挺好的,但是你有什么资本仗着自己成绩好在机房发癫,觉得自己光荣吗?
我想问一句,你是没有母本,无性生殖的产物吗????
长的跟朱元璋似的还真以为自己能诛别人九族吗
忘了,这种人本身就没有九族
说谁谁知道,自己想对号入座我也不拦着
*/
day6 7.2
今天发生啥了?
好像就是在补题
不写了
但是部分煞笔每天恶心我好几回就不地道了吧(某位天天鸡叫的唐氏小青年)
但是我好奇一件事,这是谁干的
day7 7.3
来hl一周了
上午打cf t1-t3我都不知道怎么ac的,t4不会,后来才知道不是博弈论
直接跳到了t5
暴力搜索,因为数据范围不大,索性过了
总之寄了
赞美cf的罚时制度和极其小的数据范围!!!
晚上搬寝室,但是海初宿舍的楼梯是真的高,满头大汗,赞美帮我们搬行李的hlgg
有句话说的不错,叫做学oi就像人生,退役和离世一样都是必然而无可避免的。FDsama想要送porter“最后一程”,于是协商和我换寝室。
不想写了,部分傻逼恶心死我了。说谁自己心里清楚。
寝室里其他人大多数只是问了一下我为什么和唐老师swap了,了解情况后自己忙自己的了,部分人单方面提出我前来没有经过“你们”的同意
我记得唐老师问过你们寝室的人吧
看来是没经过你本人的同意,但是你本人凭啥代表你整个寝室来冲我贴脸开大?你配吗?
你!
不!
配!
傻逼
纯傻逼
之前无数次在机房公然骂我傻逼
我知道你的名字是“傻逼”,别天天挂嘴边
唐老师想在自己回jp24之前多陪陪自己好友有什么不对(porter可爱tietie)
祝愿你爸妈死的时候没人守灵,傻逼玩意
不对,你需要父母吗?
update:我是来自7.5的zimo,根据FDsama说,上述内容在div2机房已经有人看见过了,而且都好奇是谁。
这里说一句,知道是谁对你们没有好处,想知道的自己打听,之后这些内容不再更新,也不会删除,集训结束后我会原模原样发到群里。
day8 7.4
前几天看了孙宝的博客,提到女生宿舍禁止男生入内,男寝门口没有(我想看哈利波特了)
所以这个告诉我们add(x,y)与add(y,x)是不同的
上午预习数据结构“水题”,这要是水题我tm都想退竞了
有人看B站被hzg抓包了
我不说是谁
好的,接下来说一说难评的数据结构题
偶,今天是7.5
所以就7.5再说吧
day9 7.5
好的,今天模拟——焯!
oi赛制——焯!
三个半小时——焯!
cdx:这道题如果没写到45pts你就要考虑一下这个班级是否适合你——焯!
t1是个简单无比(真的很简单)的dfs,可惜考场上没看出来,于是决定输出20pts的特殊性质骗分。但是题目审错了,cout<<0;很显然爆零了qwq。
jyy:它即使已经成星了你也可以删掉点集让度数>=3啊
好的,第二题,容斥+高维前缀和
不好意思,老子不会
t3
其实正解也快做出来了,但是时间不够,于是写暴力骗分
好的,确实没爆零
t4
我的电脑怎么有网了?哦,十一点了,算了不做了。
马上吃晚饭了,再做题肯定是不现实的
索性补一下昨天该写的数据结构题
A. New Year and Conference
好神奇的一道题,其实改一下形式化题意就简单一点了,所以用线段树维护一下就万事大吉

1 #include<bits/stdc++.h> 2 using namespace std; 3 const int maxn = 1e5+5; 4 const int inf = 0x3f3f3f3f; 5 int n,cnt,id[maxn<<2]; 6 bool flag=true; 7 inline int read() 8 { 9 int x=0,f=1; 10 char ch=getchar(); 11 while(ch<'0'||ch>'9') 12 { 13 if(ch=='-') 14 f=-1; 15 ch=getchar(); 16 } 17 while(ch>='0' && ch<='9') 18 x=x*10+ch-'0',ch=getchar(); 19 return x*f; 20 } 21 struct node 22 { 23 int s,t,x,y; 24 bool operator <(const node &a) const 25 { 26 if(x==a.x) 27 { 28 return y<a.y; 29 } 30 else return x<a.x; 31 } 32 }a[maxn]; 33 inline int ls(int x) 34 { 35 return x<<1; 36 } 37 inline int rs(int x) 38 { 39 return x<<1|1; 40 } 41 struct xds 42 { 43 int mx[maxn<<4],mn[maxn<<4]; 44 inline void build(int l,int r,int x) 45 { 46 mx[x]=0,mn[x]=inf; 47 if(l==r) 48 { 49 return; 50 } 51 int mid=(l+r)>>1; 52 build(l,mid,ls(x)); 53 build(mid+1,r,rs(x)); 54 return; 55 } 56 inline void pushup(int x) 57 { 58 mx[x]=max(mx[ls(x)],mx[rs(x)]); 59 mn[x]=min(mn[ls(x)],mn[rs(x)]); 60 } 61 inline void change(int pos,int l,int r,int x,int val) 62 { 63 if(l==r) 64 { 65 mx[x]=max(val,mx[x]); 66 mn[x]=min(val,mn[x]); 67 return; 68 } 69 int mid=(l+r)>>1; 70 if(pos<=mid) 71 { 72 change(pos,l,mid,ls(x),val); 73 } 74 else 75 { 76 change(pos,mid+1,r,rs(x),val); 77 } 78 pushup(x); 79 return; 80 } 81 inline int qumax(int lp,int rp,int l,int r,int x) 82 { 83 if(lp<=l and rp>=r) 84 { 85 return mx[x]; 86 } 87 int res=0; 88 int mid=(l+r)>>1; 89 if(lp<=mid) 90 { 91 res=max(res,qumax(lp,rp,l,mid,ls(x))); 92 } 93 if(rp>mid) 94 { 95 res=max(res,qumax(lp,rp,mid+1,r,rs(x))); 96 } 97 return res; 98 } 99 inline int qumin(int lp,int rp,int l,int r,int x) 100 { 101 if(lp<=l and rp>=r) 102 { 103 return mn[x]; 104 } 105 int res=inf; 106 int mid=(l+r)>>1; 107 if(lp<=mid) 108 { 109 res=min(res,qumin(lp,rp,l,mid,ls(x))); 110 } 111 if(rp>mid) 112 { 113 res=min(res,qumin(lp,rp,mid+1,r,rs(x))); 114 } 115 return res; 116 } 117 }t,s; 118 inline void work() 119 { 120 s.build(1,cnt,1); 121 t.build(1,cnt,1); 122 for(int i=1;i<=n;i++) 123 { 124 int maxx=t.qumax(a[i].x,cnt,1,cnt,1); 125 int minn=s.qumin(a[i].x,cnt,1,cnt,1); 126 if(minn<a[i].s or maxx>a[i].t) 127 { 128 flag=false; 129 } 130 t.change(a[i].y,1,cnt,1,a[i].s); 131 s.change(a[i].y,1,cnt,1,a[i].t); 132 } 133 } 134 int main() 135 { 136 n=read(); 137 for(int i=1;i<=n;i++) 138 { 139 a[i].x=read(); 140 a[i].y=read(); 141 a[i].s=read(); 142 a[i].t=read(); 143 id[++cnt]=a[i].x; 144 id[++cnt]=a[i].s; 145 id[++cnt]=a[i].y; 146 id[++cnt]=a[i].t; 147 } 148 sort(id+1,id+1+cnt); 149 cnt=unique(id+1,id+1+cnt)-(id+1); 150 for(int i=1;i<=n;i++) 151 { 152 a[i].x=lower_bound(id+1,id+1+cnt,a[i].x)-id; 153 a[i].y=lower_bound(id+1,id+1+cnt,a[i].y)-id; 154 a[i].s=lower_bound(id+1,id+1+cnt,a[i].s)-id; 155 a[i].t=lower_bound(id+1,id+1+cnt,a[i].t)-id; 156 } 157 sort(a+1,a+1+n); 158 work(); 159 for(int i=1;i<=n;i++) 160 { 161 swap(a[i].x,a[i].s); 162 swap(a[i].y,a[i].t); 163 } 164 sort(a+1,a+1+n); 165 work(); 166 if(flag) 167 { 168 cout<<"YES"<<endl; 169 } 170 else 171 { 172 cout<<"NO"<<endl; 173 } 174 return 0; 175 }
B. Lexicographically Small Enough
写了个树状数组

1 #include<bits/stdc++.h> 2 using namespace std; 3 typedef long long ll; 4 const int maxn = 2e5+5; 5 const ll inf = 1e18; 6 inline int read() 7 { 8 int x=0,f=1; 9 char ch=getchar(); 10 while(ch<'0'||ch>'9') 11 { 12 if(ch=='-') 13 f=-1; 14 ch=getchar(); 15 } 16 while(ch>='0' && ch<='9') 17 x=x*10+ch-'0',ch=getchar(); 18 return x*f; 19 } 20 namespace aclove //juejue 21 { 22 int n; 23 bool b[maxn]; 24 char s[maxn],t[maxn]; 25 ll ans,ans2,c[maxn]; 26 inline int lowbit(int x) 27 { 28 return (-x)&x; 29 } 30 inline void u(int p,int d) 31 { 32 for(;p<=n;p+=lowbit(p)) 33 { 34 c[p]+=d; 35 } 36 } 37 inline ll q(int p,ll s=0) 38 { 39 for(;p;p-=lowbit(p)) 40 { 41 s+=c[p]; 42 } 43 return s; 44 } 45 inline int work() 46 { 47 int T=read(); 48 while(T--) 49 { 50 ans=inf; 51 ans2=0; 52 memset(c,0,sizeof(c)); 53 memset(b,0,sizeof(b)); 54 vector<int> ap[26]; 55 n=read(); 56 scanf("%s %s",s+1,t+1); 57 for(int i=1;i<=n;i++) 58 { 59 ap[s[i]-'a'].emplace_back(i); 60 } 61 for(int i=0;i<26;i++) 62 { 63 reverse(ap[i].begin(),ap[i].end()); 64 } 65 for(int i=1,p=1,c_last;i<=n;i++) 66 { 67 while(b[p] and p<n) 68 { 69 p++; 70 } 71 if(s[p]>=t[i]) 72 { 73 c_last=n+1; 74 for(int j=0;j<t[i]-'a';j++) 75 { 76 if(ap[j].size() and *ap[j].rbegin()<c_last) 77 { 78 c_last=*ap[j].rbegin(); 79 } 80 } 81 if(c_last != n+1) 82 { 83 ans=min(ans,ans2+c_last-p+q(c_last)-q(p)); 84 } 85 } 86 else 87 { 88 ans=min(ans,ans2); 89 } 90 if(s[p]!=t[i]) 91 { 92 if(!ap[t[i]-'a'].size()) 93 { 94 break; 95 } 96 c_last=*ap[t[i]-'a'].rbegin(); 97 b[c_last]=true; 98 ans2+=c_last-p+q(c_last)-q(p); 99 u(p,1); 100 u(c_last,-1); 101 ap[t[i]-'a'].pop_back(); 102 } 103 else 104 { 105 ++p; 106 ap[t[i]-'a'].pop_back(); 107 } 108 } 109 printf("%lld\n", (ans < inf ? ans : -1)); 110 } 111 return 0; 112 } 113 } 114 using namespace aclove; 115 int main() 116 { 117 work(); 118 return 0; 119 }
C. 「Wdsr-3」令人感伤的红雨
好喜欢题面,而且做这道题的时候耳机里刚好在放《被毁坏的护身符》(风神录二面关底bgm二创),都是《東方風神錄》的产物,好耶。(秋静叶:一面道中,秋穣子:一面关底)
原题给的柿子过于“答辩”了——konata
所以给算数天才cirno化简一下
可爱的并查集

1 #include<bits/stdc++.h> 2 #define int long long 3 using namespace std; 4 const int maxn = 6e6+5; 5 int n,q,a[maxn],nxt[maxn],cost[maxn],fa[maxn]; 6 inline int read() 7 { 8 int x=0,f=1; 9 char ch=getchar(); 10 while(ch<'0'||ch>'9') 11 { 12 if(ch=='-') 13 f=-1; 14 ch=getchar(); 15 } 16 while(ch>='0' && ch<='9') 17 x=x*10+ch-'0',ch=getchar(); 18 return x*f; 19 } 20 inline int find(int x) 21 { 22 if(fa[x]==x) 23 { 24 return x; 25 } 26 else 27 { 28 return fa[x]=find(fa[x]); 29 } 30 } 31 signed main() 32 { 33 n=read(),q=read(); 34 for(int i=1;i<=n;i++) 35 { 36 a[i]=read(); 37 fa[i]=i; 38 nxt[i]=n+1; 39 cost[i]=-1; 40 } 41 int tmp=1; 42 for(int i=2;i<=n;i++) 43 { 44 if(a[i]>=a[tmp]) 45 { 46 nxt[tmp]=i; 47 cost[tmp]=a[i]-a[tmp]; 48 tmp=i; 49 } 50 else 51 { 52 fa[i]=tmp; 53 } 54 } 55 int opt,x,y,del; 56 while(q--) 57 { 58 opt=read(),x=read(),y=read(); 59 if(opt==1) 60 { 61 tmp=find(x); 62 cost[tmp]-=y; 63 while(nxt[tmp]<n+1 and cost[tmp]<0) 64 { 65 del=nxt[tmp]; 66 cost[tmp]+=cost[del]; 67 nxt[tmp]=nxt[del]; 68 fa[del]=tmp; 69 nxt[del]=n+1; 70 cost[del]=-1; 71 } 72 } 73 else 74 { 75 printf("%lld\n",max((long long)0,x-find(y))); 76 } 77 } 78 return 0; 79 }
D. Guessing Permutation for as Long as Possible
我爱国,不做日本题
好的,带权并查集

1 #include<bits/stdc++.h> 2 using namespace std; 3 const int maxn = 405; 4 const int maxm = 160005; 5 const int mod = 1e9+7; 6 inline int read() 7 { 8 int x=0,f=1; 9 char ch=getchar(); 10 while(ch<'0'||ch>'9') 11 { 12 if(ch=='-') 13 f=-1; 14 ch=getchar(); 15 } 16 while(ch>='0' && ch<='9') 17 x=x*10+ch-'0',ch=getchar(); 18 return x*f; 19 } 20 int col[maxn][maxn]; 21 int ti[maxn][maxn]; 22 int fa[maxm<<1],n,m; 23 inline int find(int x) 24 { 25 if(fa[x]==x) 26 { 27 return x; 28 } 29 else return fa[x]=find(fa[x]); 30 } 31 inline bool remerge(int x,int y) 32 { 33 if(find(x)==find(y)) 34 { 35 return 0; 36 } 37 if(find(x+m)==find(y+m)) 38 { 39 return 0; 40 } 41 fa[find(x)]=find(y+m); 42 fa[find(y)]=find(x+m); 43 return 1; 44 } 45 inline bool merge(int x,int y) 46 { 47 if(find(x)==find(y+m)) 48 { 49 return 0; 50 } 51 if(find(y)==find(x+m)) 52 { 53 return 0; 54 } 55 fa[find(x)]=find(y); 56 fa[find(x+m)]=find(y+m); 57 return 1; 58 } 59 int main() 60 { 61 n=read(); 62 m=n*(n-1)/2; 63 for(int i=1;i<=m;i++) 64 { 65 int x=read(),y=read(); 66 ti[x][y]=ti[y][x]=i; 67 } 68 for(int i=1;i<=m;i++) 69 { 70 fa[i]=i; 71 fa[i+m]=i+m; 72 } 73 for(int i=1;i<=n;i++) 74 { 75 for(int j=1;j<=n;j++) 76 { 77 for(int k=i+1;k<=n;k++) 78 { 79 if(i!=j and j!=k) 80 { 81 int tmp1=ti[i][j],tmp2=ti[i][k],tmp3=ti[j][k]; 82 if(tmp2>max(tmp1,tmp3)) 83 { 84 if(!(((i<j)^(j<k))?merge(tmp1,tmp3):remerge(tmp1,tmp3))) 85 { 86 cout<<0<<endl; 87 return 0; 88 } 89 } 90 } 91 } 92 } 93 } 94 for(int i=1;i<=m;i++) 95 { 96 if(find(i)==find(i+m)) 97 { 98 cout<<0<<endl; 99 return 0; 100 } 101 } 102 int ans=1,cnt=0; 103 for(int i=1;i<=2*m;i++) 104 { 105 if(find(i)==i) 106 { 107 cnt++; 108 } 109 } 110 for(int i=1;i<=cnt/2;i++) 111 { 112 ans=ans*2%mod; 113 } 114 cout<<ans<<endl; 115 return 0; 116 }
E. 生日礼物
第一眼没会,用了Konata讲的方法,很炸裂的stl用法

1 #include<bits/stdc++.h> 2 using namespace std; 3 inline int read() 4 { 5 int x=0,f=1; 6 char ch=getchar(); 7 while(ch<'0'||ch>'9') 8 { 9 if(ch=='-') 10 f=-1; 11 ch=getchar(); 12 } 13 while(ch>='0' && ch<='9') 14 x=x*10+ch-'0',ch=getchar(); 15 return x*f; 16 } 17 const int maxn = 1e5+5; 18 int n,m,cnt,ans,l[maxn],r[maxn],a[maxn]; 19 bool flag[maxn]; 20 priority_queue<pair<int,int>,vector<pair<int,int> >,greater<pair<int,int> > > q; 21 inline void del(int x) 22 { 23 flag[x]=1; 24 l[r[x]]=l[x]; 25 r[l[x]]=r[x]; 26 } 27 int main() 28 { 29 n=read(),m=read(); 30 int tmp=0; 31 for(int i=1;i<=n;i++) 32 { 33 int x=read(); 34 if(!x) 35 { 36 continue; 37 } 38 if(1ll*a[tmp]*x>0) 39 { 40 a[tmp]+=x; 41 } 42 else 43 { 44 a[++tmp]=x; 45 } 46 } 47 n=tmp; 48 for(int i=1;i<=n;i++) 49 { 50 if(a[i]>0) 51 { 52 cnt++; 53 ans+=a[i]; 54 } 55 l[i]=i-1; 56 r[i]=i+1; 57 q.push(make_pair(abs(a[i]),i)); 58 } 59 while(cnt>m) 60 { 61 while(flag[q.top().second]) 62 { 63 q.pop(); 64 } 65 int x=q.top().second; 66 q.pop(); 67 if((l[x] and r[x]!=n+1) or (a[x]>0)) 68 { 69 --cnt; 70 ans-=abs(a[x]); 71 a[x]+=a[l[x]]+a[r[x]]; 72 q.push(make_pair(abs(a[x]),x)); 73 del(l[x]); 74 del(r[x]); 75 } 76 else 77 { 78 del(x); 79 } 80 } 81 cout<<ans<<endl; 82 return 0; 83 }
H. 算术天才⑨与等差数列
为什么一下跳到了H
很简单,没时间做了
但是谁能拒绝cirno呢,有一说一,这道题今天早上才AC
可爱的线段树二分

1 #include<bits/stdc++.h> 2 using namespace std; 3 const int maxn = 3e5 + 5; 4 const int sgt_sz = maxn << 2; 5 const int mod = 998244353; 6 const int inf = 2147483647; 7 const int inv6 = 166374059; 8 9 inline int min(const int &a, const int &b) { return (a <= b ? a : b); } 10 inline int max(const int &a, const int &b) { return (a >= b ? a : b); } 11 12 int n, m; 13 int a[maxn]; 14 15 namespace SGT 16 { 17 #define ls (k << 1) 18 #define rs (k << 1 | 1) 19 20 int sum[sgt_sz], mnv[sgt_sz]; 21 22 void push_up(int k) { sum[k] = (sum[ls] + sum[rs]) % mod, mnv[k] = min(mnv[ls], mnv[rs]); } 23 24 void build(int k, int l, int r) 25 { 26 if (l == r) return sum[k] = 1ll * a[l] * a[l] % mod, mnv[k] = a[l], void(); 27 int mid = (l + r) >> 1; 28 build(ls, l, mid), build(rs, mid + 1, r), push_up(k); 29 } 30 31 void update(int k, int l, int r, int p, int w) 32 { 33 if (l == r) return sum[k] = 1ll * w * w % mod, mnv[k] = w, void(); 34 int mid = (l + r) >> 1; 35 if (p <= mid) update(ls, l, mid, p, w); 36 else update(rs, mid + 1, r, p, w); 37 push_up(k); 38 } 39 40 int query_min(int k, int l, int r, int ql, int qr) 41 { 42 if ((l >= ql) && (r <= qr)) return mnv[k]; 43 int mid = (l + r) >> 1, res = inf; 44 if (ql <= mid) res = min(res, query_min(ls, l, mid, ql, qr)); 45 if (qr > mid) res = min(res, query_min(rs, mid + 1, r, ql, qr)); 46 return res; 47 } 48 49 int query_sum(int k, int l, int r, int ql, int qr) 50 { 51 if ((l >= ql) && (r <= qr)) return sum[k]; 52 int mid = (l + r) >> 1, res = 0; 53 if (ql <= mid) res = (res + query_sum(ls, l, mid, ql, qr)) % mod; 54 if (qr > mid) res = (res + query_sum(rs, mid + 1, r, ql, qr)) % mod; 55 return res; 56 } 57 } 58 59 int pw2_sum(int x) { return 1ll * x * (x + 1) % mod * (2 * x + 1) % mod * inv6 % mod; } 60 61 int main() 62 { 63 // freopen("P5278_1.in", "r", stdin); 64 // freopen("P5278_1.res", "w", stdout); 65 scanf("%d%d", &n, &m); 66 for (int i = 1; i <= n; i++) scanf("%d", &a[i]); 67 SGT::build(1, 1, n); 68 int cnt = 0; 69 while (m--) 70 { 71 int op, x, y, l, r, k; 72 scanf("%d", &op); 73 if (op == 1) 74 { 75 scanf("%d%d", &x, &y); 76 x ^= cnt, y ^= cnt; 77 SGT::update(1, 1, n, x, y); 78 } 79 else 80 { 81 scanf("%d%d%d", &l, &r, &k); 82 l ^= cnt, r ^= cnt, k ^= cnt; 83 int x = SGT::query_min(1, 1, n, l, r); 84 int sum = (1ll * (r - l + 1) * x % mod * x % mod + 1ll * k * x % mod * (r - l) % mod * (r - l + 1) % mod + 1ll * k * k % mod * pw2_sum(r - l) % mod) % mod; 85 int rsum = SGT::query_sum(1, 1, n, l, r); 86 // printf("%d %d\n", sum, rsum); 87 if (sum == rsum) puts("Yes"), cnt++; 88 else puts("No"); 89 } 90 } 91 return 0; 92 }
中午花絮:那个管寝室跟管白公馆、渣滓洞一样的宿管可以去死了
这里是浙江,和重庆好像不是一个地方吧
寝室人数是生产队的驴吗?折磨精打细算
还有窗帘必须拉上两层(外面那一层跟蛇皮袋一样),不让在寝室喝汤吃泡面是什么性质
今天海宁学长去了医院,很好,就查了个血常规花费65CNY,无敌了
好的,晚上的杂题选讲
好的,又被叫到隔壁机房听cdx讲多维前缀和,留了11道题
不是,我模拟题还没补完qwq
补不完了qwq
day10 7.6
双囍临门——四喜丸子(确信)
今天模拟赛
不知道脑子怎么抽的
也可能是被前几天noip模拟赛折磨的
前2道题极其简单,我却因为觉得暴力会写挂在想别的做法
我**********************************************************************************************************************************************************************************************************************
突然想起海宁学长
用线段树做洛谷“校门外的树”(红题)
写挂了
不说了,补题去了qwq
有一说一,这场比赛图论含量好低啊
明天好像去图书馆
?!
再放送:有人劝我删除7.3的部分博客内容,我在plq解释很清楚了
寝室规则怪谈海亮信息竞赛怪谈 - 类人群星闪耀时 - 博客园 (cnblogs.com)
day11 7.7
休息日,有手机了,这是好的。
但是有人被抓到图书馆了,还有个别卷狗去机房了
怎么都这么卷
算了,反正是休息日,开摆
day12 7.8
说在前面,不要在人工智能蓬勃发展的今天挑战反作弊系统的底线,不细说了
t1 红黑树
这个东西我最开始想法是寒假曾经讲过的树上dp+树的直径
很显然我距离正解好像没差多少
然而我好像没理解题意,导致样例二都没过,很显然交上去是0分的
那么说一下正解,定义dp[x][v][2],其中‘2’代表两种状态红/黑,整个式子代表将x作为根节点且有v个顶点是黑色的方案能否可行
但是一定注意,每一个状态从哪里转移过来的
预计时间复杂度O(n*max(v)),考虑题面要求,因此是O(nlogn)

1 #include<bits/stdc++.h> 2 #define int long long 3 using namespace std; 4 const int maxn = 505; 5 bool dp[maxn][maxn][2],ans[maxn]; 6 int n,root,fa[maxn]; 7 vector<int> g[maxn]; 8 inline int read() 9 { 10 int x=0,f=1; 11 char ch=getchar(); 12 while(ch<'0' or ch>'9') 13 { 14 if(ch=='-') 15 f=-1; 16 ch=getchar(); 17 } 18 while(ch>='0' and ch<='9') 19 x=x*10+ch-'0',ch=getchar(); 20 return x*f; 21 } 22 inline void dfs(int x) 23 { 24 if(g[x].size()==0) 25 { 26 dp[x][1][1]=1; 27 dp[x][0][0]=1; 28 return; 29 } 30 if(g[x].size()==1) 31 { 32 int v=g[x][0]; 33 dfs(v); 34 dp[x][1][1]=dp[v][0][0]; 35 return; 36 } 37 for(auto v:g[x]) 38 { 39 dfs(v); 40 } 41 for(int j=0;j<=n;j++) 42 { 43 dp[x][j][0]=1; 44 for(auto v:g[x]) 45 { 46 dp[x][j][0]&=dp[v][j][1]; 47 } 48 if(!j) 49 { 50 continue; 51 } 52 dp[x][j][1]=1; 53 for(auto v:g[x]) 54 { 55 dp[x][j][1]&=(dp[v][j-1][0] or dp[v][j-1][1]); 56 } 57 } 58 return; 59 } 60 inline void work(int u,int k) 61 { 62 if(dp[u][k][1]) 63 { 64 ans[u]=1; 65 for(auto v:g[u]) 66 { 67 work(v,k-1); 68 } 69 } 70 else 71 { 72 ans[u]=0; 73 for(auto v:g[u]) 74 { 75 work(v,k); 76 } 77 } 78 return; 79 } 80 signed main() 81 { 82 //freopen("rbt.in", "r", stdin); 83 //freopen("rbt.out", "w", stdout); 84 n=read(); 85 for(int i=1;i<=n;i++) 86 { 87 fa[i]=read(); 88 if(fa[i]) 89 { 90 g[fa[i]].push_back(i); 91 } 92 else 93 { 94 root=i; 95 } 96 } 97 dfs(root); 98 for(int i=0;i<=n;i++) 99 { 100 if(dp[root][i][0] or dp[root][i][1]) 101 { 102 work(root,i); 103 for(int j=1;j<=n;j++) 104 { 105 if(ans[j]) 106 { 107 cout<<'B'; 108 } 109 else 110 { 111 cout<<'R'; 112 } 113 } 114 return 0; 115 } 116 } 117 cout<<"Impossible"<<endl; 118 return 0; 119 }
t2 xor
卢卡斯定理,高维前缀和,子集枚举,状压DP
这四个东西
Lucas:没想到,高维前缀和:刚学,不敢用,子集枚举:这是啥玩意 好像我只会状压dp
于是跳了
赛后按照cdx的题解的思路,写了一份,O(nlogn)

1 #include<bits/stdc++.h> 2 #define int long long 3 using namespace std; 4 const int maxn = 5e6+5; 5 int n,q,dep[maxn],ans,a[maxn],tmp[maxn]; 6 vector<int> g[maxn]; 7 inline int read() 8 { 9 int x=0,f=1; 10 char ch=getchar(); 11 while(ch<'0' or ch>'9') 12 { 13 if(ch=='-') 14 f=-1; 15 ch=getchar(); 16 } 17 while(ch>='0' and ch<='9') 18 x=x*10+ch-'0',ch=getchar(); 19 return x*f; 20 } 21 inline void dfs(int u,int fa) 22 { 23 dep[u]=dep[fa]+1; 24 tmp[dep[u]]^=a[u]; 25 for(auto v:g[u]) 26 { 27 if(v==fa) 28 { 29 continue; 30 } 31 dfs(v,u); 32 } 33 return; 34 } 35 signed main() 36 { 37 //freopen("xor.in","r",stdin); 38 //freopen("xor.out","w",stdout); 39 n=read(),q=read(); 40 for(int i=1;i<n;i++) 41 { 42 int u=read(),v=read(); 43 u++; 44 v++; 45 g[u].push_back(v); 46 g[v].push_back(u); 47 } 48 for(int i=1;i<=n;i++) 49 { 50 a[i]=read(); 51 } 52 dep[0]=-1; 53 dfs(1,0); 54 int inf=(1<<20)-1; 55 for(int i=0;i<20;i++) 56 { 57 for(int j=0;j<=inf;j++) 58 { 59 if((j>>i)&1) 60 { 61 tmp[j]^=tmp[j^(1<<i)]; 62 } 63 } 64 } 65 while(q--) 66 { 67 int x=read(); 68 cout<<tmp[inf^(x&inf)]<<endl; 69 } 70 return 0; 71 }
好的,t3
不会cdq分治,于是开始用线段树瞎搞,由于开t3的时候只有半小时了,没写完,乐了
但是我好奇一件事,256MB内存限制的评测机我是怎么在没分治的情况下写出MLE的
但是由于数据比较水,所以暴力维护前缀和、后缀和可以轻松卡过60pts
显然我截至撰稿都没写出正解
t4
对n和k的取值进行分类讨论
这样可以推出所有情况的式子
所以这道题是组合数学+容斥原理
由于我只写出了暴力70pts算法,索性不附上去了
今天cdx讲了cdq分治
后来撒了一些鲜花,提到了有一些去年这个时候在div3的学长,他们曾经模拟赛都是时常十几二十分甚至爆零的存在。
现在他们在哪
他们没有AFO,而是在div1为NOI冲刺
所以,为了一时榜单上的光鲜亮丽,做苟且之事不值当。选择了竞赛注定你是不凡的,也是注定你要走遍荆棘的。
也请大家给我和猫雷一次改过的机会
反正不作弊了
day13 7.9
不知不觉来hl快两周了
woc,快学考了,于是昨天晚上在寝室刷学考卷子,然而发现没有什么意义
我之前担心学考会不会考很变态的生物遗传计算题
原来是我多虑了,首先必修二基本不考,其次......如果你Aa杂交都不会你还学个**oi
好的,于是我打开了化学,有一说一,为什么把我初中就学过的东西拿出来恶心我
哦,忘了,我初中不会有机化学,乙烯加成反应?甲烷燃烧?
好的,我们接下来看看历史地理,很好,历史如果不会请反思一下自己是不是中国人
至于地理还是要好好分析一下,思维难度跟0/1背包差不多
于是zimo骂骂咧咧地收起了学考卷子
突然想起MerlinLee的一句话:毕竟有普高民办职高技校的学生也要去考,所以不用担心。
上午开始学习动态规划问题,吃灰了好几个月的六倍定理判定素数有一次派上了用场,具体的code下午再放
今天上午中考出分了,恭喜tjy学弟斩获775分的高分,对于没考好的不要气馁,作为竞赛生来日方长。
好的,一道区间dp+三道数学题
但是注意一件事情,++cnt和cnt++是完全不同的
至少a[++cnt]与a[cnt++]是不一样的
写错了你可以轻易地体会到什么叫“紫气东来”
今天tjy学弟提到了他们这一届的中考,我的评价是:我但凡晚出生一年我就不一定能去哪了
今年中考说句不好听的就是给廿四输送来了一群文科生
甚至可以说是输送来了一批废物
谁家中考酸碱盐金属盐溶液成分推断、物理混合压强还有混联电路不考的
以及那个用脚都能115+的数学卷
day14 7.10
来hl已经两周了,今天学概率期望dp
爽了
代码最少的一集
上午预习式训练,做了六道题,哦,吃饭了,不写了。
中午回寝室做学考地理卷,生物化学历史都挺好的
不是,地理我好像啥也不会
哎不是,我真就******************************************************************
化学生物学了一半的唐老师:¿
好的,下午cdx讲期望概率dp
oi是mo(确信)
不,oi是一只巨大的猫猫(雾)
突然发现,我不会懒得写LATEX
所以今天不写题解了
/******************************************************************************我是分割线********************/
突然发现,明天好像高二学长(如果排除一只D类艾希)就要奔赴国赛了
今天的夜晚属于你们,独属于你们
无论一年后的我能否走到国赛这一步
在这里祝愿4位正式选手(虽然有一位营口的,但是同样祝你顺利)在国赛上取得优异的成绩
高三很苦,不上也罢!
加油!学长学姐们!
day15 7.11
再见,波特......
上午模拟赛,希望别赤石了
按照飞机起飞的时间,讲评够呛能听完了
很好,下午回家学考,但是我地理水平能不能过都是问题啊qwq
day16 7.12
LN普通高等学校学业水平考试RP++
回家打风神录,爽!!!!!!
MD,晚上出去理发,回家没看路,摔了,脚崴了
焯!
(灯光秀以来又一次跌打损伤)7.15鲜花——2024dl24灯光秀游记 - 类人群星闪耀时 - 博客园 (cnblogs.com)
day17 7.13
今日单曲循环:《命運的陰暗面》(风神录stage2键山雏的曲子)
学考归来
上午坐飞机,浙江省云层太厚飞机降不下来,赞美绕行最后成功降落的机长
(我差点以为飞机要备降到别的城市了)
(谁家坐飞机要过三次防爆检测) 我爸:oi不能白学,各种图论算法要用上
哦,他老人家大学的时候也是学过c语言和GIS的
回机房补比赛题目
好的,清一色的弱智题
day18 7.14
摆烂
在手机上玩东方,好爽(网易云电脑)
day19 7.15
好的,尘封已久的树上算法
记得半年前好像就是在用这些东西折磨lyn学长的(bushi)
对于dfs曾经inf次写出死递归的我来说
今天好像没有那么多死递归了
爽
赞美来调研学习进度的hlgg
/*******************************************分割线*************************************************/
今天寝室发病率有点高
猫雷极度头晕难受,唐老师重感冒
至于我
昨天吃完华莱士以后,吃华莱士几乎没有出过问题的我今天拉肚子了/kel
大家都快好起来吧
番外:FDsama一直想要抱一只猫娘睡觉
这边建议你抱一只转转(键山雏)睡觉(bushi)
晚上,机房突然传来一阵骚动
洛谷炸了!!!!!!!!!
把电脑vpn打开,也不能访问
但是换个浏览器就好用了
到这里可以得出结论:某个shaber在校内局域网域名劫持,不知道用什么方式只是针对edge浏览器进行域名劫持
感觉这个“三好学生”很像键山雏(《风神录》二面关底boss)
为什么呢?
防止我们在洛谷刷题“累死”出面阻止,尽管会给他人带来厄运(指洛谷日爆)
//感兴趣的可以玩一下原作
update:网络已经在晚上9点左右恢复正常
简单说说今天做的题(知周所众,图论的代码极其长)
t1 cf1528c

1 #include<bits/stdc++.h> 2 using namespace std; 3 inline int read() 4 { 5 int x=0,f=1; 6 char ch=getchar(); 7 while(ch<'0'||ch>'9') 8 { 9 if(ch=='-') 10 f=-1; 11 ch=getchar(); 12 } 13 while(ch>='0' && ch<='9') 14 x=x*10+ch-'0',ch=getchar(); 15 return x*f; 16 } 17 const int maxn = 3e5+5; 18 const int inf = 0x3f3f3f3f; 19 int st[maxn<<1],ft[maxn<<1]; 20 vector<int> g1[maxn<<1],g2[maxn<<1]; 21 set<pair<int,int> > ps; 22 int ans,ti; 23 void dfs1(int u,int f) 24 { 25 st[u]=++ti; 26 for(auto v : g2[u]) 27 { 28 if(v==f) 29 { 30 continue; 31 } 32 dfs1(v,u); 33 } 34 ft[u]=++ti; 35 } 36 void dfs2(int u,int fa) 37 { 38 bool flag=false; 39 pair<int,int> kep; 40 auto tar=ps.lower_bound({st[u],0}); 41 if(tar==ps.end() or ft[u]<=ft[tar->second]) 42 { 43 tar=ps.upper_bound({st[u],0}); 44 if(tar!=ps.begin()) 45 { 46 tar--; 47 if(ft[u]<=ft[tar->second]) 48 { 49 kep=*tar; 50 ps.erase(tar); 51 flag=true; 52 } 53 } 54 ps.insert({st[u],u}); 55 } 56 ans=max(ans,(int)ps.size()); 57 for(auto v:g1[u]) 58 { 59 if(v==fa) 60 { 61 continue; 62 } 63 dfs2(v,u); 64 } 65 if(ps.count({st[u],u})) 66 { 67 ps.erase({st[u],u}); 68 } 69 if(flag) 70 { 71 ps.insert(kep); 72 } 73 } 74 int main() 75 { 76 int t=read(); 77 while(t--) 78 { 79 int n=read(); 80 ps.clear(); 81 for(int i=1;i<=n;i++) 82 { 83 g1[i].clear(); 84 g2[i].clear(); 85 } 86 for(int i=2;i<=n;i++) 87 { 88 int fa=read(); 89 g1[i].push_back(fa); 90 g1[fa].push_back(i); 91 } 92 for(int i=2;i<=n;i++) 93 { 94 int fa=read(); 95 g2[i].push_back(fa); 96 g2[fa].push_back(i); 97 } 98 ti=0; 99 ans=0; 100 dfs1(1,0); 101 dfs2(1,0); 102 cout<<ans<<endl; 103 } 104 return 0; 105 }
t2 cf1707c
一定注意,树上差分结束以后必须重写dfs与链前,而且链前不开二倍空间会死的很惨
qwq

1 #include<bits/stdc++.h> 2 using namespace std; 3 inline int read() 4 { 5 int x=0,f=1; 6 char ch=getchar(); 7 while(ch<'0'||ch>'9') 8 { 9 if(ch=='-') 10 f=-1; 11 ch=getchar(); 12 } 13 while(ch>='0' && ch<='9') 14 x=x*10+ch-'0',ch=getchar(); 15 return x*f; 16 } 17 const int maxn = 1e5+5; 18 int n,m,u[maxn<<1],v[maxn<<1],t[maxn]; 19 int fa[maxn],head[maxn],cnt,vis[maxn<<1]; 20 struct node 21 { 22 int to,nxt; 23 }e[maxn<<1]; 24 inline int find(int x) 25 { 26 if(fa[x]==x) 27 { 28 return x; 29 } 30 else 31 { 32 return fa[x]=find(fa[x]); 33 } 34 } 35 bool merge(int x,int y) 36 { 37 int ax=find(x),ay=find(y); 38 if(ax!=ay) 39 { 40 fa[ax]=ay; 41 return 1; 42 } 43 else 44 { 45 return 0; 46 } 47 } 48 inline void add(int u,int v) 49 { 50 e[++cnt].to=v; 51 e[cnt].nxt=head[u]; 52 head[u]=cnt; 53 } 54 void kru() 55 { 56 for(int i=1;i<=n;i++) 57 { 58 fa[i]=i; 59 } 60 for(int i=1;i<=m;i++) 61 { 62 if(merge(u[i],v[i])) 63 { 64 vis[i]=1; 65 add(u[i],v[i]); 66 add(v[i],u[i]); 67 } 68 } 69 } 70 int f[maxn][30],dep[maxn]; 71 void dfs1(int u,int far) 72 { 73 f[u][0]=far; 74 for(int i=1;i<=19;i++) 75 { 76 f[u][i]=f[f[u][i-1]][i-1]; 77 } 78 dep[u]=dep[far]+1; 79 for(int i=head[u];i;i=e[i].nxt) 80 { 81 int v=e[i].to; 82 if(v!=far) 83 { 84 dfs1(v,u); 85 } 86 } 87 } 88 int lca(int x,int y) 89 { 90 for(int i=19;i>=0;i--) 91 { 92 if(dep[f[y][i]]>=dep[x]) 93 { 94 y=f[y][i]; 95 } 96 } 97 if(x==y) 98 { 99 return x; 100 } 101 for(int i=19;i>=0;i--) 102 { 103 if(f[x][i]!=f[y][i]) 104 { 105 x=f[x][i]; 106 y=f[y][i]; 107 } 108 } 109 return f[x][0]; 110 } 111 void dfs2(int u,int far)//shu4 shang4 cha1 fen1 hou4 112 { 113 t[u]+=t[far];//qian2 zhui4 he2 114 for(int i=head[u];i;i=e[i].nxt) 115 { 116 int v=e[i].to; 117 if(v!=far) 118 { 119 dfs2(v,u); 120 } 121 } 122 } 123 int main() 124 { 125 n=read(),m=read(); 126 for(int i=1;i<=m;i++) 127 { 128 u[i]=read(),v[i]=read(); 129 } 130 kru(); 131 dfs1(1,0); 132 for(int i=1;i<=m;i++) 133 { 134 if(!vis[i]) 135 { 136 if(dep[u[i]]>dep[v[i]]) 137 { 138 swap(u[i],v[i]); 139 } 140 int tmp=lca(u[i],v[i]); 141 if(u[i]==tmp) 142 { 143 t[1]++; 144 t[v[i]]++; 145 int x=v[i]; 146 for(int j=19;j>=0;j--) 147 { 148 if(dep[f[x][j]]>dep[u[i]]) 149 { 150 x=f[x][j]; 151 } 152 } 153 t[x]--; 154 } 155 else 156 { 157 t[u[i]]++; 158 t[v[i]]++; 159 } 160 } 161 } 162 dfs2(1,0); 163 for(int i=1;i<=n;i++) 164 { 165 if(t[i]==m-(n-1)) 166 { 167 cout<<"1"; 168 } 169 else 170 { 171 cout<<"0"; 172 } 173 } 174 cout<<endl; 175 return 0; 176 }
t3 运输计划
折磨喜闻乐见的题目索性不赘述了

1 /* 2 略 3 */
day20 7.16
上午很显然,模拟赛
但是有人却在寝室休息,怎么会逝呢
至于模拟赛的题目,难以评价
t1按照题中给的比重,暴力期望得分30pts
结果得了70pts,赞美不杀之恩的rfy
t2乍一眼并不会,因为线段树写挂了/kel
后来才知道,这道题暴力模拟可以得到60pts
t3很有趣
定义dp[i][j]表示在第一天已经用了j小时的情况下完成i子树中的所有题目最少还需要多少天多少小时
用O(m!)复杂度遍历所有子树即可
后来才知道,这样做期望50pts
然而我考完试才发觉:
"我t2不是没做吗,我怎么交了一份代码?!"
“我t3交哪去了?!”
RE,50pts->0pts
t4没做,但是听说dj算法可以骗分20pts
订正去了
晚上讲基础容斥和二项式反演,这是好的
day21 7.17
上午模拟赛,寄了
值得一提的是,t3那道题我想出来了正解,使用dp+滚动数组,为了防止被卡常用了vector存图
但是还是寄了
我单独开了个结构体负责存对于图的询问(共q个询问)
然后我再对这个结构体进行sort的时候写成了
sort(qu+1,qu+1+n);
好巧不巧的,样例过了,交上去,100pts->0pts
焯!
t2好熟悉的样子,原来是酒店开关灯问题,梦开始的地方!!!!
但是数据范围1e18的你见过吗?!
热知识这道题暴力模拟没有分
下午和可爱的__int128斗智斗勇,事实证明__int128不能在Windows下编译
我****************************************************
day22 7.18
二分图,但是有霍尔定理没有匈牙利算法,怎么回事呢
“匈牙利算法是NOI级别的算法,所以不讲了。”——CDX
晚上的时候再附上几道题吧
今天FDsama又一次撑不住了,望早日康复
由于博客内容有限,所以选择几道有代表性的题目。
t1,原题是hdu的acm考试题,翻译一下就是对于一个给定的图,删去最少的边使其变成二分图
其实枚举即可,枚举左右分布情况并且删除想同一侧的边就可以了

1 #include<bits/stdc++.h> 2 using namespace std; 3 #define map Deaphets 4 int t,n,m,map[20][20],fa[20],a[20],b[20],ans; 5 inline int read() 6 { 7 int x=0,f=1; 8 char ch=getchar(); 9 while(ch<'0'||ch>'9') 10 { 11 if(ch=='-') 12 f=-1; 13 ch=getchar(); 14 } 15 while(ch>='0' && ch<='9') 16 x=x*10+ch-'0',ch=getchar(); 17 return x*f; 18 } 19 int main() 20 { 21 t=read(); 22 while(t--) 23 { 24 memset(map,0,sizeof(map)); 25 n=read(),m=read(); 26 for(int i=1;i<=m;i++) 27 { 28 int u=read(),v=read(); 29 map[u][v]++; 30 map[v][u]++; 31 } 32 ans=0x3f3f3f3f; 33 for(int i=1;i<=(1<<n);i++) 34 { 35 int maxx=0; 36 int cnta=0,cntb=0; 37 memset(a,0,sizeof(a)); 38 memset(b,0,sizeof(b)); 39 for(int j=1;j<=n;j++) 40 { 41 if(i&(1<<(j-1))) 42 { 43 a[++cnta]=j; 44 } 45 else 46 { 47 b[++cntb]=j; 48 } 49 } 50 for(int j=1;j<=cnta;j++) 51 { 52 for(int k=j+1;k<=cnta;k++) 53 { 54 if(map[a[j]][a[k]]) 55 { 56 maxx+=map[a[j]][a[k]]; 57 } 58 } 59 } 60 for(int j=1;j<=cntb;j++) 61 { 62 for(int k=j+1;k<=cntb;k++) 63 { 64 if(map[b[j]][b[k]]) 65 { 66 maxx+=map[b[j]][b[k]]; 67 } 68 } 69 } 70 ans=min(ans,maxx); 71 } 72 cout<<ans<<endl; 73 } 74 return 0; 75 }
t2,p1285,队员分组
事实证明,当你做题卡住的时候不建议和屎山代码死磕,在确保算法正确的前提下建议直接重构

1 #include<bits/stdc++.h> 2 using namespace std; 3 const int maxn = 105; 4 inline int read() 5 { 6 int x=0,f=1; 7 char ch=getchar(); 8 while(ch<'0'||ch>'9') 9 { 10 if(ch=='-') 11 f=-1; 12 ch=getchar(); 13 } 14 while(ch>='0' && ch<='9') 15 x=x*10+ch-'0',ch=getchar(); 16 return x*f; 17 } 18 vector<int> e[maxn],vec[maxn][2],ans[2]; 19 inline void add(int u,int v) 20 { 21 e[u].push_back(v); 22 } 23 int n,tmp[maxn][maxn],dp[maxn][maxn],opt[maxn][maxn]; 24 int vis[maxn],col[maxn],cnt; 25 inline bool bfs(int x) 26 { 27 queue<int> q; 28 q.push(x); 29 vis[x]=1; 30 cnt++; 31 while(!q.empty()) 32 { 33 int u=q.front(); 34 q.pop(); 35 vec[cnt][col[u]].push_back(u); 36 for(auto v:e[u]) 37 { 38 if(!vis[v]) 39 { 40 col[v]=col[u]^1; 41 vis[v]=1; 42 q.push(v); 43 } 44 else 45 { 46 if(col[v]==col[u]) 47 { 48 return false; 49 } 50 } 51 } 52 } 53 return true; 54 } 55 inline void work() 56 { 57 n=read(); 58 for(int u=1;u<=n;u++) 59 { 60 int v; 61 while((v=read())) 62 { 63 tmp[u][v]=1; 64 } 65 } 66 for(int u=1;u<=n;u++) 67 { 68 for(int v=u+1;v<=n;v++) 69 { 70 if(!(tmp[u][v] and tmp[v][u])) 71 { 72 add(u,v); 73 add(v,u); 74 } 75 } 76 } 77 for(int i=1;i<=n;i++) 78 { 79 if(!vis[i] and !bfs(i)) 80 { 81 cout<<"No solution"<<endl; 82 return; 83 } 84 } 85 dp[0][0]=1; 86 for(int i=1;i<=cnt;i++) 87 { 88 for(int j=0;j<=n;j++) 89 { 90 if(j>=vec[i][0].size() and dp[i-1][j-vec[i][0].size()]) 91 { 92 dp[i][j]=1; 93 opt[i][j]=0; 94 } 95 if(j>=vec[i][1].size() and dp[i-1][j-vec[i][1].size()]) 96 { 97 dp[i][j]=1; 98 opt[i][j]=1; 99 } 100 } 101 } 102 int now; 103 for(int i=(n>>1);i>=0;i--) 104 { 105 if(dp[cnt][i]) 106 { 107 now=i; 108 break; 109 } 110 } 111 for(int i=cnt;i>=1;i--) 112 { 113 for(auto x:vec[i][opt[i][now]]) 114 { 115 ans[0].push_back(x); 116 } 117 for(auto x:vec[i][opt[i][now]^1]) 118 { 119 ans[1].push_back(x); 120 } 121 now-=vec[i][opt[i][now]].size(); 122 } 123 sort(ans[0].begin(),ans[0].end()); 124 sort(ans[1].begin(),ans[1].end()); 125 cout<<(int)ans[0].size()<<" "; 126 for(auto x:ans[0]) 127 { 128 cout<<x<<" "; 129 } 130 cout<<endl; 131 cout<<(int)ans[1].size()<<" "; 132 for(auto x:ans[1]) 133 { 134 cout<<x<<" "; 135 } 136 cout<<endl; 137 } 138 int main() 139 { 140 work(); 141 return 0; 142 }
可以先求出补图,对于补图中的每个连通块可以知道两边点数 ai,bi,其实在这个时候就相当于在维护对于每个连通块可以向左侧加上ai或者bi,最终让两侧的差值最小
这个时候尘封已久的背包dp就派上用场了
乐
t3,p10572
好新的一道月赛题
其实二分图我们可以把它视作为两个集合,这样一来就可以使用并查集维护二分图。
但是一定注意,由于图可能不是连通的,对于每一个连通块必须判断一次奇环

1 #include<bits/stdc++.h> 2 using namespace std; 3 inline int read() 4 { 5 int x=0,f=1; 6 char ch=getchar(); 7 while(ch<'0'||ch>'9') 8 { 9 if(ch=='-') 10 f=-1; 11 ch=getchar(); 12 } 13 while(ch>='0' && ch<='9') 14 x=x*10+ch-'0',ch=getchar(); 15 return x*f; 16 } 17 const int maxn = 5e5+5; 18 int v[maxn],fa[maxn<<1],fa1[maxn<<1],fa2[maxn<<1],fa3[maxn<<1]; 19 int tag1[maxn],tag2[maxn],jh[maxn],ans[maxn]; 20 string s; 21 struct node 22 { 23 int fi,se; 24 }e[maxn<<1]; 25 inline int find(int *fa,int x) 26 { 27 if(fa[x]==x) 28 { 29 return x; 30 } 31 return fa[x]=find(fa,fa[x]); 32 } 33 int main() 34 { 35 int n=read(),m=read(),q=read(); 36 cin>>s; 37 for(int i=1;i<=n;i++) 38 { 39 if(s[i-1]=='(') 40 { 41 v[i]=1; 42 } 43 else 44 { 45 v[i]=-1; 46 } 47 } 48 for(int i=1;i<=n;i++) 49 { 50 fa1[i]=fa2[i]=fa3[i]=i; 51 } 52 for(int i=1;i<=(n<<1);i++) 53 { 54 fa[i]=i; 55 } 56 for(int i=1;i<=m;i++) 57 { 58 e[i].fi=read(),e[i].se=read(); 59 int x=e[i].fi,y=e[i].se; 60 if(find(fa,x)!=find(fa,y+n)) 61 { 62 fa[find(fa,x)]=find(fa,y+n); 63 } 64 if(find(fa,y)!=find(fa,x+n)) 65 { 66 fa[find(fa,y)]=find(fa,x+n); 67 } 68 if(!(v[x]==-1 and v[y]==-1)) 69 { 70 if(find(fa1,x)!=find(fa1,y)) 71 { 72 fa1[find(fa1,x)]=find(fa1,y); 73 } 74 } 75 if(!(v[x]==1 and v[y]==1)) 76 { 77 if(find(fa2,x)!=find(fa2,y)) 78 { 79 fa2[find(fa2,x)]=find(fa2,y); 80 } 81 } 82 if(!(v[x]==-1 and v[y]==-1) and !(v[x]==1 and v[y]==1)) 83 { 84 if(find(fa3,x)!=find(fa3,y)) 85 { 86 fa3[find(fa3,x)]=find(fa3,y); 87 } 88 } 89 } 90 for(int i=1;i<=m;i++) 91 { 92 int x=e[i].fi,y=e[i].se; 93 if(find(fa,x)==find(fa,x+n)) 94 { 95 jh[find(fa,x)]=1; 96 } 97 if(find(fa,y)==find(fa,y+n)) 98 { 99 jh[find(fa,y)]=1; 100 } 101 } 102 for(int i=1;i<=m;i++) 103 { 104 int x=e[i].fi,y=e[i].se; 105 if(v[x]==1 and v[y]==1) 106 { 107 tag1[find(fa1,x)]=1; 108 } 109 if(v[x]==-1 and v[y]==-1) 110 { 111 tag2[find(fa2,x)]=1; 112 } 113 } 114 for(int i=1;i<=q;i++) 115 { 116 int x=read(),y=read(); 117 if(find(fa,x)!=find(fa,y) and find(fa,x)!=find(fa,y+n)) 118 { 119 continue; 120 } 121 if(v[x]!=1 or v[y]!=-1) 122 { 123 continue; 124 } 125 if((!jh[find(fa,x)]) and (find(fa,x)==find(fa,y))) 126 { 127 continue; 128 } 129 if(find(fa3,x)==find(fa3,y)) 130 { 131 ans[i]=1; 132 } 133 else if(tag1[find(fa1,x)] and tag2[find(fa2,y)]) 134 { 135 ans[i]=1; 136 } 137 } 138 for(int i=1;i<=q;i++) 139 { 140 cout<<ans[i]; 141 } 142 cout<<endl; 143 return 0; 144 }
先扔几个典题在这里吧
/************************************************可爱的分割线***************************/
喜报:tjy以775pts的成绩被大连市第二十四中录取,祝贺你成为了一位“骄傲而无所畏惧”的二十四中人。
/*********************************************************************************************************/
t4,做了一个逆天改命的行为,我想尝试写一份人生中第二份网络流(尽管可以写二分图)
好的,写了半个多小时做出来了

1 #include<bits/stdc++.h> 2 using namespace std; 3 inline int read() 4 { 5 int x=0,f=1; 6 char ch=getchar(); 7 while(ch<'0'||ch>'9') 8 { 9 if(ch=='-') 10 f=-1; 11 ch=getchar(); 12 } 13 while(ch>='0' && ch<='9') 14 x=x*10+ch-'0',ch=getchar(); 15 return x*f; 16 } 17 inline int lowbit(int x) 18 { 19 return (-x)&x; 20 } 21 const int maxn = 25; 22 const int maxm = 4e6+5; 23 int n,k,a[maxn],s[maxm],f[1<<18]; 24 int cnt[1<<18]; 25 bool check(int m) 26 { 27 memset(f,0,sizeof(f)); 28 for(int i=1;i<=m;i++) 29 { 30 f[s[i]]++; 31 } 32 for(int i=0;i<n;i++) 33 { 34 for(int j=0;j<(1<<n);j++) 35 { 36 if(!((j>>i)&1)) 37 { 38 f[j]+=f[j|(1<<i)]; 39 } 40 } 41 } 42 for(int i=1;i<(1<<n);i++) 43 { 44 if(m-f[i]+(n-cnt[i])*k<n*k) 45 { 46 return 0; 47 } 48 } 49 return 1; 50 } 51 int main() 52 { 53 for(int i=1;i<(1<<18);i++) 54 { 55 cnt[i]=cnt[i-lowbit(i)]+1; 56 } 57 n=read(),k=read(); 58 for(int i=1;i<=n;i++) 59 { 60 a[i]=read(); 61 for(int j=0;j<=2*n*k;j+=2*a[i]) 62 { 63 for(int k=1;k<=a[i];k++) 64 { 65 s[j+k]|=(1<<(i-1)); 66 } 67 } 68 } 69 for(int i=0;i<=2*n*k;i++) 70 { 71 s[i]^=(1<<n)-1; 72 } 73 int l=n*k,r=2*n*k; 74 int ans=r+1; 75 while(l<=r) 76 { 77 int mid=(l+r)>>1; 78 if(check(mid)) 79 { 80 ans=mid; 81 r=mid-1; 82 } 83 else 84 { 85 l=mid+1; 86 } 87 } 88 cout<<ans<<endl; 89 return 0; 90 }
其实不难发现N最大只有18,所以先建立网络流模型,然后第二层表示人,第三层表示天数,最大匹配等于最小割,割去除了第二层之外的所有都可以。对于第一层直接状压,因为不大可能大于等于18,然后考虑第三层有哪些需要割掉的。哦,原来是剩下点里可以通向第三层点的交集。
然后高维前缀和预处理,再写一个二分判断一下是否存在无法完全匹配的方案。
结束了。
day23 7.19
上午模拟赛,可惜这次暴力没有出奇迹,个人承认二分图并不难,但是今天比赛题目有很多“充分发扬人类智慧”的做法
t1,meet
有n个网红要见面,给出了每个人的n-1个期望见面顺序
当你在写二分图正解的时候,有人已经puts(“-1”);拿到20pts了,怎么回事呢

1 #include<bits/stdc++.h> 2 using namespace std; 3 inline int read() 4 { 5 int x=0,f=1; 6 char ch=getchar(); 7 while(ch<'0'||ch>'9') 8 { 9 if(ch=='-') 10 f=-1; 11 ch=getchar(); 12 } 13 while(ch>='0' && ch<='9') 14 x=x*10+ch-'0',ch=getchar(); 15 return x*f; 16 } 17 const int maxn = 1e3+5; 18 const int maxm = 1e6+5; 19 int n,id[maxn][maxn],lst[maxn],m,deg[maxm]; 20 int ans,day[maxm],vis; 21 vector<int> e[maxm]; 22 queue<int> q; 23 int main() 24 { 25 freopen("meet.in","r",stdin); 26 freopen("meet.out","w",stdout); 27 n=read(); 28 for(int i=1;i<=n;i++) 29 { 30 for(int j=i+1;j<=n;j++) 31 { 32 id[i][j]=id[j][i]=++m; 33 } 34 } 35 for(int i=1;i<=n;i++) 36 { 37 for(int j=1;j<n;j++) 38 { 39 int tmp=read(); 40 int now=id[i][tmp]; 41 if(lst[i]) 42 { 43 e[lst[i]].push_back(now); 44 deg[now]++; 45 } 46 lst[i]=now; 47 } 48 } 49 for(int i=1;i<=m;i++) 50 { 51 if(!deg[i]) 52 { 53 q.push(i); 54 day[i]=1; 55 } 56 } 57 while(!q.empty()) 58 { 59 int u=q.front(); 60 q.pop(); 61 ans=max(ans,day[u]); 62 vis++; 63 for(auto v:e[u]) 64 { 65 deg[v]--; 66 day[v]=max(day[v],day[u]+1); 67 if(deg[v]==0) 68 { 69 q.push(v); 70 } 71 } 72 } 73 if(vis==m) 74 { 75 cout<<ans<<endl; 76 } 77 else 78 { 79 puts("-1"); 80 } 81 return 0; 82 }
t2,由于题目过于答辩,于是考试的时候并没有做
后来发现,打表好像挺好使的
确实是这样,唯一缺点是码量爆炸,极其难调试(不建议展开下面的代码,否则可能导致浏览器卡死)

1 #include<bits/stdc++.h> 2 using namespace std; 3 inline int read() 4 { 5 int x=0,f=1; 6 char ch=getchar(); 7 while(ch<'0'||ch>'9') 8 { 9 if(ch=='-') 10 f=-1; 11 ch=getchar(); 12 } 13 while(ch>='0' && ch<='9') 14 x=x*10+ch-'0',ch=getchar(); 15 return x*f; 16 } 17 bool dp[105][105]; 18 int x[30005][6]; 19 int main() 20 { 21 freopen("bulb.in","r",stdin); 22 freopen("bulb.out","w",stdout); 23 int t=read(); 24 while(t--) 25 { 26 int n=read(),m=read(),ans=0; 27 for(int i=1;i<=n;i++) 28 { 29 for(int j=1;j<=m;j++) 30 { 31 char c; 32 cin>>c; 33 dp[i][j]=c-'0'; 34 } 35 } 36 for(int i=1;i<n-1;i++) 37 { 38 for(int j=1;j<m;j++) 39 { 40 if(dp[i][j]==1) 41 { 42 if(dp[i][j+1]==1) 43 { 44 ans++; 45 x[ans][0]=i; 46 x[ans][1]=j; 47 x[ans][2]=i; 48 x[ans][3]=j+1; 49 x[ans][4]=i+1; 50 x[ans][5]=j; 51 dp[i][j]^=1; 52 dp[i][j+1]^=1; 53 dp[i+1][j]^=1; 54 } 55 else 56 { 57 ans++; 58 x[ans][0]=i; 59 x[ans][1]=j; 60 x[ans][2]=i+1; 61 x[ans][3]=j+1; 62 x[ans][4]=i+1; 63 x[ans][5]=j; 64 dp[i][j]^=1; 65 dp[i+1][j+1]^=1; 66 dp[i+1][j]^=1; 67 } 68 } 69 else 70 { 71 if(dp[i][j+1]==1) 72 { 73 ans++; 74 x[ans][0]=i; 75 x[ans][1]=j+1; 76 x[ans][2]=i+1; 77 x[ans][3]=j+1; 78 x[ans][4]=i+1; 79 x[ans][5]=j; 80 dp[i][j+1]^=1; 81 dp[i+1][j+1]^=1; 82 dp[i+1][j]^=1; 83 } 84 } 85 } 86 } 87 for(int j=1;j<m-1;j++) 88 { 89 if(dp[n-1][j]==1) 90 { 91 if(dp[n][j]==1) 92 { 93 ans++; 94 x[ans][0]=n-1; 95 x[ans][1]=j; 96 x[ans][2]=n; 97 x[ans][3]=j; 98 x[ans][4]=n-1; 99 x[ans][5]=j+1; 100 dp[n-1][j]^=1; 101 dp[n][j]^=1; 102 dp[n-1][j+1]^=1; 103 } 104 else 105 { 106 ans++; 107 x[ans][0]=n-1; 108 x[ans][1]=j; 109 x[ans][2]=n-1; 110 x[ans][3]=j+1; 111 x[ans][4]=n; 112 x[ans][5]=j+1; 113 dp[n-1][j]^=1; 114 dp[n-1][j+1]^=1; 115 dp[n][j+1]^=1; 116 } 117 } 118 else 119 { 120 if(dp[n][j]==1) 121 { 122 ans++; 123 x[ans][0]=n; 124 x[ans][1]=j; 125 x[ans][2]=n; 126 x[ans][3]=j+1; 127 x[ans][4]=n-1; 128 x[ans][5]=j+1; 129 dp[n][j]^=1; 130 dp[n][j+1]^=1; 131 dp[n-1][j+1]^=1; 132 } 133 } 134 } 135 while(1) 136 { 137 int cnt=0; 138 if(dp[n-1][m-1]==1) 139 { 140 cnt++; 141 } 142 if(dp[n][m-1]==1) 143 { 144 cnt++; 145 } 146 if(dp[n-1][m]==1) 147 { 148 cnt++; 149 } 150 if(dp[n][m]==1) 151 { 152 cnt++; 153 } 154 if(cnt==0) 155 { 156 break; 157 } 158 if(cnt==4) 159 { 160 ans++; 161 x[ans][0]=n-1; 162 x[ans][1]=m-1; 163 x[ans][2]=n; 164 x[ans][3]=m-1; 165 x[ans][4]=n-1; 166 x[ans][5]=m; 167 dp[n-1][m-1]^=1; 168 dp[n][m-1]^=1; 169 dp[n-1][m]^=1; 170 } 171 else if(cnt==3) 172 { 173 ans++; 174 int tmp=0; 175 if(dp[n-1][m-1]==1) 176 { 177 x[ans][tmp]=n-1; 178 x[ans][tmp+1]=m-1; 179 dp[n-1][m-1]^=1; 180 tmp+=2; 181 } 182 if(dp[n][m-1]==1) 183 { 184 x[ans][tmp]=n; 185 x[ans][tmp+1]=m-1; 186 dp[n][m-1]^=1; 187 tmp+=2; 188 } 189 if(dp[n-1][m]==1) 190 { 191 x[ans][tmp]=n-1; 192 x[ans][tmp+1]=m; 193 dp[n-1][m]^=1; 194 tmp+=2; 195 } 196 if(dp[n][m]==1) 197 { 198 x[ans][tmp]=n; 199 x[ans][tmp+1]=m; 200 dp[n][m]^=1; 201 tmp+=2; 202 } 203 } 204 else if(cnt<=2) 205 { 206 ans++; 207 int hh=0,hb=0,hw=0; 208 if(dp[n-1][m-1]==1 and hw<1) 209 { 210 x[ans][hh]=n-1; 211 x[ans][hh+1]=m-1; 212 hh+=2; 213 hw++; 214 dp[n-1][m-1]^=1; 215 } 216 else if(dp[n-1][m-1]==0 and hb<2) 217 { 218 x[ans][hh]=n-1; 219 x[ans][hh+1]=m-1; 220 hh+=2; 221 hb++; 222 dp[n-1][m-1]^=1; 223 } 224 if(dp[n-1][m]==1 and hw<1) 225 { 226 x[ans][hh]=n-1; 227 x[ans][hh+1]=m; 228 hh+=2; 229 hw++; 230 dp[n-1][m]^=1; 231 } 232 else if(dp[n-1][m]==0 and hb<2) 233 { 234 x[ans][hh]=n-1; 235 x[ans][hh+1]=m; 236 hh+=2; 237 hb++; 238 dp[n-1][m]^=1; 239 } 240 if(dp[n][m-1]==1 and hw<1) 241 { 242 x[ans][hh]=n; 243 x[ans][hh+1]=m-1; 244 hh+=2; 245 hw++; 246 dp[n][m-1]^=1; 247 } 248 else if(dp[n][m-1]==0 and hb<2) 249 { 250 x[ans][hh]=n; 251 x[ans][hh+1]=m-1; 252 hh+=2; 253 hb++; 254 dp[n][m-1]^=1; 255 } 256 if(dp[n][m]==1 and hw<1) 257 { 258 x[ans][hh]=n; 259 x[ans][hh+1]=m; 260 hh+=2; 261 hw++; 262 dp[n][m]^=1; 263 } 264 else if(dp[n][m]==0 and hb<2) 265 { 266 x[ans][hh]=n; 267 x[ans][hh+1]=m; 268 hh+=2; 269 hb++; 270 dp[n][m]^=1; 271 } 272 } 273 } 274 cout<<ans<<endl; 275 for(int i=1;i<=ans;i++) 276 { 277 for(int j=0;j<=5;j++) 278 { 279 cout<<x[i][j]<<" "; 280 } 281 cout<<endl; 282 } 283 } 284 return 0; 285 }
t3,当你开始效仿昨天树上括号匹配那道题的做法开始写二分图或者像我一样写唐氏暴力dp的时候你已经输了
(尽管正解是dp,但是此处想说一种抽象的做法)
据某位热心群众发现,这道题cout<<k<<endl;可以拿到30pts
而且这道题常数很小
所以......
为了这道题,我甚至去Wikipedia上学习了一下Mersenne Twister
c语言代码如下:

1 #include <stdint.h> 2 3 #define n 624 4 #define m 397 5 #define w 32 6 #define r 31 7 #define UMASK (0xffffffffUL << r) 8 #define LMASK (0xffffffffUL >> (w-r)) 9 #define a 0x9908b0dfUL 10 #define u 11 11 #define s 7 12 #define t 15 13 #define l 18 14 #define b 0x9d2c5680UL 15 #define c 0xefc60000UL 16 #define f 1812433253UL 17 18 typedef struct 19 { 20 uint32_t state_array[n]; // the array for the state vector 21 int state_index; // index into state vector array, 0 <= state_index <= n-1 always 22 } mt_state; 23 24 25 void initialize_state(mt_state* state, uint32_t seed) 26 { 27 uint32_t* state_array = &(state->state_array[0]); 28 29 state_array[0] = seed; // suggested initial seed = 19650218UL 30 31 for (int i=1; i<n; i++) 32 { 33 seed = f * (seed ^ (seed >> (w-2))) + i; // Knuth TAOCP Vol2. 3rd Ed. P.106 for multiplier. 34 state_array[i] = seed; 35 } 36 37 state->state_index = 0; 38 } 39 40 41 uint32_t random_uint32(mt_state* state) 42 { 43 uint32_t* state_array = &(state->state_array[0]); 44 45 int k = state->state_index; // point to current state location 46 // 0 <= state_index <= n-1 always 47 48 // int k = k - n; // point to state n iterations before 49 // if (k < 0) k += n; // modulo n circular indexing 50 // the previous 2 lines actually do nothing 51 // for illustration only 52 53 int j = k - (n-1); // point to state n-1 iterations before 54 if (j < 0) j += n; // modulo n circular indexing 55 56 uint32_t x = (state_array[k] & UMASK) | (state_array[j] & LMASK); 57 58 uint32_t xA = x >> 1; 59 if (x & 0x00000001UL) xA ^= a; 60 61 j = k - (n-m); // point to state n-m iterations before 62 if (j < 0) j += n; // modulo n circular indexing 63 64 x = state_array[j] ^ xA; // compute next value in the state 65 state_array[k++] = x; // update new state value 66 67 if (k >= n) k = 0; // modulo n circular indexing 68 state->state_index = k; 69 70 uint32_t y = x ^ (x >> u); // tempering 71 y = y ^ ((y << s) & b); 72 y = y ^ ((y << t) & c); 73 uint32_t z = y ^ (y >> l); 74 75 return z; 76 }
来源:Wikipedia
所以可以发扬人类智慧,直接写随机化

1 #include<bits/stdc++.h> 2 using namespace std; 3 mt19937 mt_rand(random_device{}()); 4 int rnd(int l,int r) 5 { 6 return mt_rand()%(r-l+1)+l; 7 } 8 inline int read() 9 { 10 int x=0,f=1; 11 char ch=getchar(); 12 while(ch<'0'||ch>'9') 13 { 14 if(ch=='-') 15 f=-1; 16 ch=getchar(); 17 } 18 while(ch>='0' && ch<='9') 19 x=x*10+ch-'0',ch=getchar(); 20 return x*f; 21 } 22 const int maxn = 1e5+5; 23 int n,k,ans=1e9,a[maxn],p[maxn]; 24 int dp[maxn][1<<5]; 25 vector<int> e[maxn]; 26 void dfs(int u,int fa) 27 { 28 dp[u][1<<p[a[u]]]=1; 29 for(auto v:e[u]) 30 { 31 if(v==fa) 32 { 33 continue; 34 } 35 dfs(v,u); 36 for(int i=(1<<k)-1;i>=0;i--) 37 { 38 for(int j=0;j<(1<<k);j++) 39 { 40 dp[u][i|j]=min(dp[u][i|j],dp[v][j]+dp[u][i]); 41 } 42 } 43 } 44 ans=min(ans,dp[u][(1<<k)-1]); 45 } 46 int main() 47 { 48 //freopen("insect.in","r",stdin); 49 //freopen("insect.out","w",stdout); 50 n=read(),k=read(); 51 set<int> q; 52 for(int i=1;i<=n;i++) 53 { 54 scanf("%d",a+i); 55 q.insert(a[i]); 56 } 57 for(int i=1;i<n;i++) 58 { 59 int u=read(),v=read(); 60 e[u].push_back(v); 61 e[v].push_back(u); 62 } 63 if(q.size()<=k) 64 { 65 memset(dp,0x3f3f3f,sizeof(dp)); 66 int j=0; 67 for(auto i:q) 68 { 69 p[i]=j++; 70 } 71 dfs(1,0); 72 cout<<ans<<endl; 73 return 0; 74 } 75 for(int i=1;i<=50;i++) 76 { 77 memset(dp,0x3f,sizeof(dp)); 78 for(int j=1;j<=n;j++) 79 { 80 p[j]=rnd(0,k-1); 81 } 82 dfs(1,0); 83 } 84 cout<<ans<<endl; 85 return 0; 86 }
其实上述代码可以为对拍写某个区间内的随机数提供思路
晚上讲整体二分,但是为什么rfy的代码有种oiwiki的美感?
番外:这几天寝室晚上的话题有点炸裂了
day24 7.20
上午周赛,下午就有手机了,赢!
下午陆续收到了两位学长的退役感言
其实还是很悲伤的
后人奋发吧
day25 7.21
休息一下吧!
day26 7.22
上午进行了“选水题讲“,对于一道博弈论题目我交了人生中第二篇题解,希望赶紧过审。
感谢在题目中出fft的cdx
不说了,补题去了
谴责某个背刺所有竞赛生去三寰牧场研学的学校
day27 7.23
说在前面:你谷管理员是不学语文吗,个人觉得高中语文水平读懂绰绰有余
题解被打回来了/kel
上午又是喜闻乐见的模拟
t1
暴力模拟竟然有50pts,其实把柿子简单化简一下
然后就过了
t2
当时没时间做了,于是直接输出1骗分
正解是将一个挡板拆点为4个点,离散化之后直接跑bfs即可
t3
赛时切了,先看chker得出n-2
然后乱搞+数学归纳法
t4
倍增+分块,做过原题,比赛的时候出于公平性原则没交
还有个t5,是省选班的试题,只能说是很有高考数学t19的风范
update:题解终于™过审了
day28 7.24
至此终章
上午预习分块,下午回家
完结撒花~~~~
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· winform 绘制太阳,地球,月球 运作规律
· AI与.NET技术实操系列(五):向量存储与相似性搜索在 .NET 中的实现
· 超详细:普通电脑也行Windows部署deepseek R1训练数据并当服务器共享给他人
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 上周热点回顾(3.3-3.9)