首页 > 其他分享 >【Codeforces】补题合集

【Codeforces】补题合集

时间:2023-02-18 20:45:05浏览次数:64  
标签:typedef ch const int Codeforces long 补题 合集 define

Educational Codeforces Round 143 (Rated for Div. 2)

A. Two Towers

拼接序列。枚举相邻相同字母。如果 \(>1\) 则无解。否则可以做一个断点,有解。

点击查看代码
// Problem: A. Two Towers
// Contest: Codeforces - Educational Codeforces Round 143 (Rated for Div. 2)
// URL: https://codeforces.com/contest/1795/problem/A
// Memory Limit: 256 MB
// Time Limit: 2000 ms
// 
// Powered by CP Editor (https://cpeditor.org)
 
#include <bits/stdc++.h>
using namespace std;
 
#define Multicase() for(int T = read() ; T ; T--)
#define lowbit(x) (x & (-x))
#define ls(p) (p<<1)
#define rs(p) (p<<1|1)
#define l(p) tree[p].ls
#define r(p) tree[p].rs
#define sum(p) tree[p].sum
#define tag(p) tree[p].tag
#define F(i,a,b) for(int i=(a) ;i<=(b);++i)
#define F2(i,a,b) for(int i=(a);i< (b);++i)
#define dF(i,a,b) for(int i=(a);i>=(b);--i)
#define debug(...) fprintf(stderr,__VA_ARGS__)
#define Debug debug("Passing [%s] in LINE %d\n",__FUNCTION__,__LINE__)
#define clr(a,x) memset(a,x,sizeof(a))
#define pb push_back
#define mkp make_pair
#define fi first
#define se second
#define endl '\n'
#define ENDL putchar('\n')
#define forGraph(u) for(int i=head[u];i;i=G[i].next)
 
const int N=5e5+5;
const int M=1e6+5;
const int MN=1e3+5;
const int iinf=INT_MAX;
const double eps=1e-9;
const double pi=acos(-1);
const long long linf=LLONG_MAX;
const long long mod=1000000007,mod2=998244353;
 
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef map<string,int> msi;
 
inline int read(){int x(0), f(0); char ch=getchar(); while(ch<'0'||ch>'9'){f|=ch=='-';ch=getchar();} while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+(ch^48); ch=getchar();} return f?-x:x;}
template <typename T> void read(T &x){x=0; T f(0); char ch=getchar(); while(ch<'0'||ch>'9'){f|=ch=='-';ch=getchar();} while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+(ch^48); ch=getchar();} x=f?-x:x;}
template <typename T,typename ...Arg>void read(T& x,Arg& ...arg){read(x);read(arg...);}
template <typename T> inline void write(T x){static char buf[64]; static int tot(0); if(x<0) putchar('-'),x=-x; do buf[++tot]=(x%10)+48,x/=10; while(x); do putchar(buf[tot--]); while(tot);}
template <typename T> void write(T x,char c){static char buf[64]; static int tot(0); if(x<0) putchar('-'),x=-x; do buf[++tot]=(x%10)+48,x/=10; while(x); do putchar(buf[tot--]); while(tot); putchar(c);}
void judge(bool x){printf(x?"YES\n":"NO\n");}
 
void Solve();
 
struct Graph{
    int to,w,next;
}G[M<<1];
int head[N],cnt;
void addEdge(int u,int v,int w=1){G[++cnt]=(Graph){v,w,head[u]}; head[u]=cnt;}
 
template<class T,class U> void chkmax(T &x, U y) { if(x < y) x = y; }
template<class T,class U> void chkmin(T &x, U y) { if(x > y) x = y; }
 
int n,m,q,k,p;
int a[N],b[N],f[N];
vector<int> v;
 
int main(){
    Multicase()
        Solve();
}
 
string s,t;
 
void Solve(){
	p=0;
	read(n,m);
	cin>>s>>t;
	reverse(t.begin(),t.end());
	s+=t;
	F(i,1,n+m-1) if(s[i]==s[i-1]) p++;
	if(p<=1) judge(1);
	else judge(0);
}

标签:typedef,ch,const,int,Codeforces,long,补题,合集,define
From: https://www.cnblogs.com/TheSky233/p/17133537.html

相关文章

  • apple365的分治合集!
    目录根号分治待补正文根号分治其实分块也是一种根号分治。本质是将一组询问按照某个值域来划分(通常取根号),不超过\(X\)时采用一种做法,超过了换另一种(一般一种是暴......
  • k8s 常用命令合集
    kubernetemaster只运行集群组件,nodes运行pods。Taints表示污点的意思,如果node描述信息有该选项表示不可调度.kubectldescribenodecentos-04取消污点kubectltaintn......
  • 很简单 但又一时想不起来的功能合集
     ///<summary>///根据模型的尺寸取得的模型边缘位置与模型中心的相对位置(在不适用物理的情况下模型移动式避免穿模)///</summary>varbounds=GetComponent<Mesh......
  • 3. 投票 案例项目(合集)
    3.投票-1创建项目和子应用创建项目命令$pythondjango-adminstartprojectmysite目录结构mysite/#项目容器、可任意命名manage.py......
  • Educational Codeforces Round 143 (Rated for Div. 2) A-E
    比赛链接A题意有两座塔由红蓝方块组成,分别有\(n,m\)个方块,一次操作可以把一座塔塔顶的方块移动到另一座塔的塔顶,问通过操作是否能使每座塔中没有颜色相同的相邻方块。......
  • Educational Codeforces Round 142 (Rated for Div. 2)
    D.FixedPrefixPermutations题目大意给定两个排列\(p,q\),\(r=p\cdotq\)表示\(r_j=q_{p_j}\)。一个排列\(p\)的美丽值为满足\(p_1=1,\p_2=2,\p_3=3,\\cdots,\p_k=......
  • Educational Codeforces Round 143 (Rated for Div. 2)
    E.Explosions?题目抽象为现有长度为\(n\)的数组\(a_1,a_2,\cdots,a_n\)\((1\lea_i\le10^{6})\)。定义满足以下条件的区间\([l,r]\)\((1\lel,r\len)\)为爆炸......
  • Educational Codeforces Round 143 (Rated for Div. 2)
    题目链接A这个题目其实乍一看还比较麻烦,其实很简单。其实像这种题目我们只需要构造出来一个最基本的需要操作的情况,然后可以往这种操作最多可以进行多少次这个方向来思考......
  • Educational Codeforces Round 102 (Rated for Div. 2)D(线段树求贡献)
    EducationalCodeforcesRound102(RatedforDiv.2)D(线段树求贡献)D.Program题目大意:最初x为0,给定一个长度为n的操作序列,共有两种操作:-,x-=1;+,x+=1;有m次询......
  • 一些关于网站推广问题合集。
    网站怎么快速上权重?要让一个网站快速提高权重,需要实施以下一些有效的策略:提供高质量的内容:提供高质量、原创、有用的内容是最重要的。这可以吸引更多的用户访问,并增加用......