当前位置:网站首页>2022/7/16
2022/7/16
2022-07-19 10:52:00 【killer_ queen4804】
Mark and His Unfinished Essay
This question can only be done after reading the train of thought tips , In fact, it should be made by yourself , It's not hard to
Copy every time l,r They all survive. , And find the prefix sum of the length copied each time , Every time k Two points to find greater than or equal to k The location of , Then find out where it belongs last time , until k<=n You can output it directly
[ Two points ]Mark and His Unfinished Essay CF1705C_CCloth The blog of -CSDN Blog
#include <bits/stdc++.h>
#define ll long long
#define lowbit(x) ((x)&(-x))
using namespace std;
const ll mod=998244353;
ll t,n,c,q,sum[55];
struct node{
ll l,r;
}a[55];
char s[8000005];
int main(){
scanf("%lld",&t);
while(t--){
scanf("%lld%lld%lld",&n,&c,&q);
scanf("%s",s+1);
sum[0]=n;
for(int i=1;i<=c;i++) scanf("%lld%lld",&a[i].l,&a[i].r),sum[i]=sum[i-1]+a[i].r-a[i].l+1;
while(q--){
ll k;
scanf("%lld",&k);
ll x=lower_bound(sum,sum+c+1,k)-sum;
while(k>n){
k=a[x].l+k-sum[x-1]-1;
x=lower_bound(sum,sum+c+1,k)-sum;
}
cout<<s[k]<<'\n';
}
for(int i=1;i<=c;i++) sum[i]=0;
}
return 0;
}
D- Xiao Hong's construction problem _ The bullock practice match 100 (nowcoder.com)
See the official solution , consider rerere This sequence , At the first re After add 1 individual d There will be more 1 individual red, In the 2 individual re After add d There will be more 3 individual , In the k individual re There will be more k*(k+1)/2 individual , Consider each re Put one in the back d, Then the sum is 1+3+...+k*(k+1)/2, That is to say n*(n+1)*(n+2)/6, Use this to find out the maximum number needed in the code re
#include <bits/stdc++.h>
#define ll long long
#define lowbit(x) ((x)&(-x))
using namespace std;
const ll mod=998244353;
ll n,tx[101010];
int main(){
cin>>n;
ll x;
if(n==0) return cout<<"d",0;
for(x=1;x*(x+1)*(x+2)/6<=n;x++);x--;
for(ll j=x;j>=1;j--){
tx[j]+=n/(j*(j+1)/2);
n%=j*(j+1)/2;
}
for(ll j=1;j<=x;j++){
cout<<"re";
while(tx[j]--) cout<<"d";
}
return 0;
}
P2024 [NOI2001] The food chain - Luogu | New ecology of computer science education (luogu.com.cn) Union checking set
This problem is changed from two-level category and search set to 3 On the floor , Pay attention to the relationship between the three cycles , hypothesis x This class ,x+n yes x Edible class ,x+2*n Yes, it can be eaten x Class , Then pay attention to some details
#include <bits/stdc++.h>
#define ll long long
#define lowbit(x) ((x)&(-x))
using namespace std;
const ll mod=998244353;
ll n,k,s[200005],ans=0;
ll findd(ll x){
return x==s[x]?x:s[x]=findd(s[x]);
}
void uni(ll x,ll y){
ll xx=findd(x),yy=findd(y);
if(xx!=yy) s[xx]=yy;
}
int main(){
scanf("%lld%lld",&n,&k);
for(int i=1;i<=n;i++) s[i]=i,s[i+n]=i+n,s[i+2*n]=i+2*n;
for(int i=1;i<=k;i++){
ll op,x,y;
scanf("%lld%lld%lld",&op,&x,&y);
if(x>n||y>n){ans++;continue;}
if(op==1){
if(findd(x+n)==findd(y)||findd(x)==findd(y+n)){ans++;continue;}
uni(x,y);
uni(x+n,y+n);
uni(x+2*n,y+2*n);
}
else{
if(findd(x)==findd(y)||findd(x)==findd(y+n)||findd(x+2*n)==findd(y)||x==y){ans++;continue;}
uni(x,y+2*n);
uni(x+n,y);
uni(x+2*n,y+n);
}
}
printf("%lld\n",ans);
return 0;
}
边栏推荐
- Journal日志与oplog日志的区别
- Pytorch.nn实现多层感知机
- 新增、修改操作时自定义复杂逻辑校验-2022新项目
- Common collection properties
- Brush questions with binary tree (2)
- [design process] Net ORM FreeSQL wheredynamicfilter dynamic table query function
- Scala在Idea中的配量
- 2022/7/16
- LeetCode 2331. Calculate the value of Boolean binary tree (tree traversal)
- LeetCode 2325. Decrypt message (map)
猜你喜欢

Establishment of redis cluster, one master, two slave and three Sentinels

机器学习模型的评估方法

vSphere 下借助 vDS 或 NSX 做端口镜像的方法总结

unity3d如何利用asset store下载一些有用的资源包

Pytoch framework learning record 1 cifar-10 classification

如何在双链笔记软件中建立仪表盘和知识库?以嵌入式小组件库 NotionPet 为例

Know what it is, and know why, JS object creation and inheritance

ENVI_IDL:使用反距离权重法选取最近n个点插值(底层实现)并输出为Geotiff格式(效果等价于Arcgis中反距离权重插值)

How to use SVG to make text effects arranged along any path

High number_ Chapter 1 space analytic geometry and vector algebra__ Distance from point to plane
随机推荐
Opencv programming: opencv3 X trains its own classifier
人大、微软等提出InclusiveFL:异构设备上的包容性联邦学习
Win10 start key click no response
"Baidu side" angrily sprayed the interviewer! Isn't it that the tree time increases by a line number?
新增、修改操作時自定義複雜邏輯校驗-2022新項目
[LeetCode周赛复盘] 第 302 场周赛20220717
Satellite network capacity improvement method based on network coding
SAP ECC 和 S4HANA Material 物料库存管理的模型比较
Integrated network architecture and network slicing technology of air, earth and sea
破案了卧槽---从MQ消费的逻辑怎么改代码都不生效
37. Flex layout
二分类学习推广到多分类学习
手机键盘(模拟题)
37. flex布局
Efficient space-based computing technology for satellite communication in 6g
vSphere 下借助 vDS 或 NSX 做端口镜像的方法总结
LeetCode 2331. Calculate the value of Boolean binary tree (tree traversal)
Transplant Wu Enda's deep learning 01 machine learning and neural network second week neural network basic programming homework elective homework to pycharm
基于网络编码的卫星网络容量提升方法
[acwing] 60th weekly match b- 4495 Array operation