A-A

http://162.14.124.219/contest/1006/problem/A

考查用vector画图

我枚举到n==5才开始用,浪费40分钟,还是找规律太慢,得多学

做题代码如下:一坨

#include <bits/stdc++.h>

using namespace std;

using ll =long long;
const ll N =1e6+8;
char v[1000001];
int w[10000001]; ll diff[N],prefix[N];
vector<vector<char>> generate_carpet(int N) {
if (N == 0) {
return {{'#'}};
} vector<vector<char>> smaller_carpet = generate_carpet(N - 1);
int size = smaller_carpet.size();
int new_size = size * 3;
vector<vector<char>> new_carpet(new_size, vector<char>(new_size, '.')); for (int i = 0; i < new_size; ++i) {
for (int j = 0; j < new_size; ++j) {
if (!(size <= i && i < 2 * size && size <= j && j < 2 * size)) {
new_carpet[i][j] = smaller_carpet[i % size][j % size];
}
}
} return new_carpet;
} void print_carpet(const vector<vector<char>>& carpet) {
for (const auto& row : carpet) {
for (char ch : row) {
cout << ch;
}
cout << endl;
}
}
int main(){
ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
ll n;
cin>>n;
if(n==1){
cout<<"###"<<'\n';
cout<<"#.#"<<'\n';
cout<<"###"<<'\n';
}else if(n==2){
cout<<"#########"<<'\n';
cout<<"#.##.##.#"<<'\n';
cout<<"#########"<<'\n';
cout<<"###...###"<<'\n';
cout<<"#.#...#.#"<<'\n';
cout<<"###...###"<<'\n';
cout<<"#########"<<'\n';
cout<<"#.##.##.#"<<'\n';
cout<<"#########"<<'\n';
}else if(n==0){
cout<<"#"<<'\n';
}else if(n==3)
{
cout<<"###########################"<<'\n';
cout<<" #.##.##.##.##.##.##.##.##.#"<<'\n';
cout<<"###########################"<<'\n';
cout<<"###...######...######...###"<<'\n';
cout<<"#.#...#.##.#...#.##.#...#.#"<<'\n';
cout<<"###...######...######...###"<<'\n';
cout<<"###########################"<<'\n';
cout<<"#.##.##.##.##.##.##.##.##.#"<<'\n';
cout<<"###########################"<<'\n';
cout<<"#########.........#########"<<'\n';
cout<<"#.##.##.#.........#.##.##.#"<<'\n';
cout<<"#########.........#########"<<'\n';
cout<<"###...###.........###...###"<<'\n';
cout<<"#.#...#.#.........#.#...#.#"<<'\n';
cout<<"###...###.........###...###"<<'\n';
cout<<"#########.........#########"<<'\n';
cout<<"#.##.##.#.........#.##.##.#"<<'\n';
cout<<"#########.........#########"<<'\n';
cout<<"###########################"<<'\n';
cout<<"#.##.##.##.##.##.##.##.##.#"<<'\n';
cout<<"###########################"<<'\n';
cout<<"###...######...######...###"<<'\n';
cout<<"#.#...#.##.#...#.##.#...#.#"<<'\n';
cout<<"###...######...######...###"<<'\n';
cout<<"###########################"<<'\n';
cout<<"#.##.##.##.##.##.##.##.##.#"<<'\n';
cout<<"###########################"<<'\n'; }else if(n==4){
cout<<"#################################################################################"<<'\n';
cout<<"#.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.#"<<'\n';
cout<<"#################################################################################"<<'\n';
cout<<"###...######...######...######...######...######...######...######...######...###"<<'\n';
cout<<"#.#...#.##.#...#.##.#...#.##.#...#.##.#...#.##.#...#.##.#...#.##.#...#.##.#...#.#"<<'\n';
cout<<"###...######...######...######...######...######...######...######...######...###"<<'\n';
cout<<"#################################################################################"<<'\n';
cout<<"#.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.#"<<'\n';
cout<<"#################################################################################"<<'\n';
cout<<"#########.........##################.........##################.........#########"<<'\n';
cout<<"#.##.##.#.........#.##.##.##.##.##.#.........#.##.##.##.##.##.#.........#.##.##.#"<<'\n';
cout<<"#########.........##################.........##################.........#########"<<'\n';
cout<<"###...###.........###...######...###.........###...######...###.........###...###"<<'\n';
cout<<"#.#...#.#.........#.#...#.##.#...#.#.........#.#...#.##.#...#.#.........#.#...#.#"<<'\n';
cout<<"###...###.........###...######...###.........###...######...###.........###...###"<<'\n';
cout<<"#########.........##################.........##################.........#########"<<'\n';
cout<<"#.##.##.#.........#.##.##.##.##.##.#.........#.##.##.##.##.##.#.........#.##.##.#"<<'\n';
cout<<"#########.........##################.........##################.........#########"<<'\n';
cout<<"#################################################################################"<<'\n';
cout<<"#.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.#"<<'\n';
cout<<"#################################################################################"<<'\n';
cout<<"###...######...######...######...######...######...######...######...######...###"<<'\n';
cout<<"#.#...#.##.#...#.##.#...#.##.#...#.##.#...#.##.#...#.##.#...#.##.#...#.##.#...#.#"<<'\n';
cout<<"###...######...######...######...######...######...######...######...######...###"<<'\n';
cout<<"#################################################################################"<<'\n';
cout<<"#.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.#"<<'\n';
cout<<"#################################################################################"<<'\n';
cout<<"###########################...........................###########################"<<'\n';
cout<<"#.##.##.##.##.##.##.##.##.#...........................#.##.##.##.##.##.##.##.##.#"<<'\n';
cout<<"###########################...........................###########################"<<'\n';
cout<<"###...######...######...###...........................###...######...######...###"<<'\n';
cout<<"#.#...#.##.#...#.##.#...#.#...........................#.#...#.##.#...#.##.#...#.#"<<'\n';
cout<<"###...######...######...###...........................###...######...######...###"<<'\n';
cout<<"###########################...........................###########################"<<'\n';
cout<<"#.##.##.##.##.##.##.##.##.#...........................#.##.##.##.##.##.##.##.##.#"<<'\n';
cout<<"###########################...........................###########################"<<'\n';
cout<<"#########.........#########...........................#########.........#########"<<'\n';
cout<<"#.##.##.#.........#.##.##.#...........................#.##.##.#.........#.##.##.#"<<'\n';
cout<<"#########.........#########...........................#########.........#########"<<'\n';
cout<<"###...###.........###...###...........................###...###.........###...###"<<'\n';
cout<<"#.#...#.#.........#.#...#.#...........................#.#...#.#.........#.#...#.#"<<'\n';
cout<<"###...###.........###...###...........................###...###.........###...###"<<'\n';
cout<<"#########.........#########...........................#########.........#########"<<'\n';
cout<<"#.##.##.#.........#.##.##.#...........................#.##.##.#.........#.##.##.#"<<'\n';
cout<<"#########.........#########...........................#########.........#########"<<'\n';
cout<<"###########################...........................###########################"<<'\n';
cout<<"#.##.##.##.##.##.##.##.##.#...........................#.##.##.##.##.##.##.##.##.#"<<'\n';
cout<<"###########################...........................###########################"<<'\n';
cout<<"###...######...######...###...........................###...######...######...###"<<'\n';
cout<<"#.#...#.##.#...#.##.#...#.#...........................#.#...#.##.#...#.##.#...#.#"<<'\n';
cout<<"###...######...######...###...........................###...######...######...###"<<'\n';
cout<<"###########################...........................###########################"<<'\n';
cout<<"#.##.##.##.##.##.##.##.##.#...........................#.##.##.##.##.##.##.##.##.#"<<'\n';
cout<<"###########################...........................###########################"<<'\n';
cout<<"#################################################################################"<<'\n';
cout<<"#.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.#"<<'\n';
cout<<"#################################################################################"<<'\n';
cout<<"###...######...######...######...######...######...######...######...######...###"<<'\n';
cout<<"#.#...#.##.#...#.##.#...#.##.#...#.##.#...#.##.#...#.##.#...#.##.#...#.##.#...#.#"<<'\n';
cout<<"###...######...######...######...######...######...######...######...######...###"<<'\n';
cout<<"#################################################################################"<<'\n';
cout<<"#.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.#"<<'\n';
cout<<"#################################################################################"<<'\n';
cout<<"#########.........##################.........##################.........#########"<<'\n';
cout<<"#.##.##.#.........#.##.##.##.##.##.#.........#.##.##.##.##.##.#.........#.##.##.#"<<'\n';
cout<<"#########.........##################.........##################.........#########"<<'\n';
cout<<"###...###.........###...######...###.........###...######...###.........###...###"<<'\n';
cout<<"#.#...#.#.........#.#...#.##.#...#.#.........#.#...#.##.#...#.#.........#.#...#.#"<<'\n';
cout<<"###...###.........###...######...###.........###...######...###.........###...###"<<'\n';
cout<<"#########.........##################.........##################.........#########"<<'\n';
cout<<"#.##.##.#.........#.##.##.##.##.##.#.........#.##.##.##.##.##.#.........#.##.##.#"<<'\n';
cout<<"#########.........##################.........##################.........#########"<<'\n';
cout<<"#################################################################################"<<'\n';
cout<<"#.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.#"<<'\n';
cout<<"#################################################################################"<<'\n';
cout<<"###...######...######...######...######...######...######...######...######...###"<<'\n';
cout<<"#.#...#.##.#...#.##.#...#.##.#...#.##.#...#.##.#...#.##.#...#.##.#...#.##.#...#.#"<<'\n';
cout<<"###...######...######...######...######...######...######...######...######...###"<<'\n';
cout<<"#################################################################################"<<'\n';
cout<<"#.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.#"<<'\n';
cout<<"#################################################################################"<<'\n'; }else{
vector<vector<char>> carpet = generate_carpet(n);
print_carpet(carpet); } }

B-B

http://162.14.124.219/contest/1006/problem/B

就是问你字符串里面有多少个连续相同的两个的子串数量,

但是问的是某一个区间里面的。

思路就是先找出所有的子串,然后再开一个数组,保存子串的数量在位置上

然后利用一个前缀和就可以找到答案了

#include <bits/stdc++.h>

using namespace std;

using ll =long long;
const ll N =1e6+8;
char v[1000001];
int w[10000001]; ll diff[N],prefix[N];
int main(){
ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
ll n,q;
cin>>n>>q;
for(int i=1;i<=n;i++){
cin>>v[i];
}
for(int i=1;i<=n;i++){
if((v[i]==v[i+1])){
w[i]=1;
}
}
for(int j=1;j<=n;j++) prefix[j]=prefix[j-1]+w[j];
while(q--){
ll l,r;
cin>>l>>r;
if(w[r]==1){
cout<<prefix[r]-prefix[l-1]-1<<'\n';
}else{
cout<<prefix[r]-prefix[l-1]<<'\n';
} } }

C-C
最近在训练二分,可惜前面时间浪费太多,现在看到很高兴,会做了。
思路==就是二分加模拟,判断条件是最多行数>=使用的数量,这样模拟,把每一个数
加在一个数中,如果这个数小于二分的答案继续加下一个,直到大于等于,然后行数加1
(就是每一行要满足二分的答案),最后如果行数超了限制说明大了,如果可以继续二分继续变大==
代码如下:

#include <bits/stdc++.h>
using namespace std; using ll =long long; const ll inf = 2e18; vector<ll>v(10000001); ll m,n;
bool check(ll x){
vector<ll>pd(1);
for(int i=1;i<=n;i++){
if(v[i]>x) return false;
if(pd.back()==0){
pd.back()+=v[i];
}else{
if(pd.back()+v[i]+1ll<=x){
pd.back()+=1ll+v[i];
}else
pd.push_back(v[i]);
}
}
return pd.size()<=m;
} int main(){
ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
cin>>n>>m;
for(int i=1;i<=n;i++)cin>>v[i];
ll l=1,r=inf;
ll ans=-1;
while(l<=r){
ll mid =(l+r)>>1;
if(check(mid)) ans=mid,r=mid-1;
else l=mid+1; }
cout<<ans;
return 0; }

SMU Summer 2024 Contest Round 2 (7.9)zhaosang的更多相关文章

  1. Codeforces Round #581(Div. 2)

    Codeforces Round #581(Div. 2) CF 1204 A. BowWow and the Timetable 题解:发现,$4$的幂次的二进制就是一个$1$后面跟偶数个$0$. ...

  2. Cow Contest POJ - 3660 (floyd 传递闭包)

    N (1 ≤ N ≤ 100) cows, conveniently numbered 1..N, are participating in a programming contest. As we ...

  3. 【CodeForces - 1200C】Round Corridor (数论gcd)

    Round Corridor  Descriptions Amugae位于一个非常大的圆形走廊中.走廊由两个区域组成.内部区域等于nñ扇区,外部区域等于m米部门.在相同区域(内部或外部)的每对扇区之间 ...

  4. Educational Codeforces Round 29(6/7)

    1.Quasi-palindrome 题意:问一个字符串(你可以添加前导‘0’或不添加)是否是回文串 思路:将给定的字符串的前缀‘0’和后缀‘0’都去掉,然后看其是否为回文串 #include< ...

  5. Codeforces Round #334(div.2)(新增不用二分代码) B

    B. More Cowbell time limit per test 2 seconds memory limit per test 256 megabytes input standard inp ...

  6. Round Numbers (排列组合)

    Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 7558   Accepted: 2596 Description The c ...

  7. codeforces Round #389(Div.2)C Santa Claus and Robot(思维题)

    题目链接:http://codeforces.com/contest/752/problem/C 题意:给出一系列机器人的行动方向(机器人会走任意一条最短路径),问最少标记几个点能让机器人按这个 路径 ...

  8. Codeforces Round #626 (Div. 2) B. Count Subrectangles

    题目连接:https://codeforces.com/contest/1323/problem/B 题意:给一个大小为n的a数组,一个大小为m的b数组,c数组是二维数组c[i][j]=a[i]*b[ ...

  9. 2017-2018 ACM-ICPC German Collegiate Programming Contest (GCPC 2017)(9/11)

    $$2017-2018\ ACM-ICPC\ German\ Collegiate\ Programming\ Contest (GCPC 2017)$$ \(A.Drawing\ Borders\) ...

  10. Codeforces Round #342 (Div 2) 解题报告

    除夕夜之有生之年CF第一场 下午从奶奶家回到姥姥家,一看还有些时间,先吃点水果陪姥姥姥爷聊了会儿,再一看表,5:20....woc已经开场20分钟了...于是抓紧时间乱搞.. **A. Guest F ...

随机推荐

  1. Android 13 - Media框架(4)- MediaPlayerService

    关注公众号免费阅读全文,进入音视频开发技术分享群! MediaPlayerService是android的多媒体框架的核心服务之一,该服务存储有android平台所支援的编解码器信息,管理所有通过Me ...

  2. Dockerfile-NGINX镜像制作

    1 NGINX镜像制作: 1.1 NGINX-dockerfile FROM centos:7 LABEL maintainer www.chenleilei.net RUN useradd www ...

  3. 算法金 | Python 中有没有所谓的 main 函数?为什么?

    ​大侠幸会,在下全网同名[算法金] 0 基础转 AI 上岸,多个算法赛 Top [日更万日,让更多人享受智能乐趣] 定义和背景 在讨论Python为何没有像C或Java那样的明确的main函数之前,让 ...

  4. C基本知识

    1 C基本数据类型 C基本的数据类型说明: 2 字节序 测试代码: #include <stdio.h> typedef unsigned char *byte_pointer; void ...

  5. Linux间进程通信--消息队列

    本系列文章主要是学习记录Linux下进程间通信的方式. 常用的进程间通信方式:管道.FIFO.消息队列.信号量以及共享存储. 参考文档:<UNIX环境高级编程(第三版)> 参考视频:Lin ...

  6. Python实现求多个集合之间的并集-方法2

    之前使用过一种方法实现求集合间的并集,参考文章:https://www.cnblogs.com/mrlayfolk/p/12373532.html,这次使用另外一种方法实现,这种方法效率更高. 目的: ...

  7. elementUI slider组件,带范围选择实现双向绑定

    网上查过很多相关文章都没有一章是写element ui滑块带范围实现双向绑定 二个滑块二头的数据怎么得到 我的需求是做个时间轴要滑动选择不同的时间 开始很难做最后一点一点摸索得出的结论 好在写出来了先 ...

  8. CF1836

    A.Destroyer 开个桶记录个数,看满不满足单调不上升即可. B.Astrophysicists 辛辛苦苦写了这么久的文章就没了????烦死了. 自己做 Virtual Contest 的时候这 ...

  9. Linux虚拟网卡TUN和TAP

    简介 在 Linux 网络管理中,虚拟网卡(Virtual Network Interface)是一个重要的概念,广泛应用于虚拟化.网络仿真和隧道技术中.本文将重点介绍 TUN(Network TUN ...

  10. Linux多网卡的bond模式原理

    Linux多网卡绑定 ​ 网卡绑定mode共有7种: bond0,bond1,bond2,bond3,bond4,bond5,bond6,bond7 常用的有三种: ​ mode=0: 平衡负载模式, ...