D. Rudolf and the Ball Game
1.B. Rudolf and 1212.C. Rudolf and the Ugly String3.A. Rudolf and the Ticket
4.D. Rudolf and the Ball Game
5.G. Rudolf and Subway6.C. Choose the Different Ones!7.B. Following the String8.E. Klever Permutation9.D. Find the Different Ones!10.B. YetnotherrokenKeoard11.C. Removal of Unattractive Pairs12.D. Jumping Through Segments13.E. Good Triples14.F. Shift and Reverse15.C. Nikita and LCM16.B. Prefiquence17.E. Vlad and a Pair of Numbers18.D. XOR Construction19.C. Non-coprime Split20.D. Divide and Equalize21.E. Block Sequence22.D. In Love23.C. Theofanis' Nightmare24.D. Yet Another Monster Fight25.C. Count Triangles26.E. Count Paths27.Collecting Numbers II28.C. Even Subarrays29.C. Perform Operations to Maximize Score30.F. Color Rows and Columns31.C. To Become Max题解:模拟+去重
每一次扔球都将所有可能性加入队列,并设为一层;然后将一层的可能性挨个出列并进行 ((qj+ri−1) mod n+1),((qj−ri−1+n) mod n+1)操作,然后去重后入列。
code
#include<bits/stdc++.h> using namespace std; const int N=2e5+5; int a[N],b[1005]; int main(){ // freopen("input.txt","r",stdin); int t; cin>>t; while (t--){ int n,m,x; cin>>n>>m>>x; int r=0,l=0; a[r++]=x; for (int i=1;i<=m;i++){ memset(b,0,sizeof(b)); int ri,R=r; char c; cin>>ri>>c; while (l<R){ int zero=(a[l]+ri-1)%n+1,one=(a[l]+n-ri-1)%n+1; if (c=='?') { if (b[zero]==0){ a[r++]=zero; b[zero]=1; } if (b[one]==0){ a[r++]=one; b[one]=1; } } if (c=='0') if (b[zero]==0){ a[r++]=zero; b[zero]=1; } if (c=='1') if (b[one]==0){ a[r++]=one; b[one]=1; } l++; } } cout<<r-l<<endl; sort(a+l,a+r); cout<<a[l++]; while (l<r) cout<<" "<<a[l++]; cout<<endl; } return 0; }
合集:
codeforces
分类:
刷题
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· winform 绘制太阳,地球,月球 运作规律
· AI与.NET技术实操系列(五):向量存储与相似性搜索在 .NET 中的实现
· 超详细:普通电脑也行Windows部署deepseek R1训练数据并当服务器共享给他人
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 上周热点回顾(3.3-3.9)