A. Specific Tastes of Andre

题意:构造一个长度为n且任意子串和整除其长度的序列。

思路:n个1就行。

view code
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<map>
#include <queue>
#include<sstream>
#include <stack>
#include <set>
#include <bitset>
#include<vector>
#define FAST ios::sync_with_stdio(false)
#define abs(a) ((a)>=0?(a):-(a))
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mem(a,b) memset(a,b,sizeof(a))
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define rep(i,a,n) for(int i=a;i<=n;++i)
#define per(i,n,a) for(int i=n;i>=a;--i)
#define endl '\n'
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef pair<ll,ll> PII;
const int maxn = 1e5+200;
const int inf=0x3f3f3f3f;
const double eps = 1e-7;
const double pi=acos(-1.0);
const int mod = 1e9+7;
inline int lowbit(int x){return x&(-x);}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
void ex_gcd(ll a,ll b,ll &d,ll &x,ll &y){if(!b){d=a,x=1,y=0;}else{ex_gcd(b,a%b,d,y,x);y-=x*(a/b);}}//x=(x%(b/d)+(b/d))%(b/d);
inline ll qpow(ll a,ll b,ll MOD=mod){ll res=1;a%=MOD;while(b>0){if(b&1)res=res*a%MOD;a=a*a%MOD;b>>=1;}return res;}
inline ll inv(ll x,ll p){return qpow(x,p-2,p);}
inline ll Jos(ll n,ll k,ll s=1){ll res=0;rep(i,1,n+1) res=(res+k)%i;return (res+s)%n;}
inline ll read(){ ll f = 1; ll x = 0;char ch = getchar();while(ch>'9'||ch<'0') {if(ch=='-') f=-1; ch = getchar();}while(ch>='0'&&ch<='9') x = (x<<3) + (x<<1) + ch - '0', ch = getchar();return x*f; }
int dir[4][2] = { {1,0}, {-1,0},{0,1},{0,-1} }; int main()
{
int kase;
cin>>kase;
while(kase--)
{
ll n = read();
rep(i,1,n) cout<<1<<' ';
cout<<endl;
}
return 0;
}

B. Valerii Against Everyone

题意:给你一个b数组,对应a数组为\(a[i] = 2{^{b[i]}}\)。问你序列中有没有相互不重合且和相同的子串。

思路:看成二进制,\(2{^{b[i]}}\)看成是第b[i]+1个位置(从低位开始)是1其他是0的二进制数。

1.首先有两个相同的二进制数肯定满足题意。

2.其他情况下,若要产生相同的和,那必须要是两边构成的数相同,或者有一边是通过进位产生新高位才相同的。而后者又需要有相同的数(\(2{^{b[i]}}\)在两个相同的数才能产生进位)。

所以只用判断是否有相同的数存在即可。

view code
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<map>
#include <queue>
#include<sstream>
#include <stack>
#include <set>
#include <bitset>
#include<vector>
#define FAST ios::sync_with_stdio(false)
#define abs(a) ((a)>=0?(a):-(a))
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mem(a,b) memset(a,b,sizeof(a))
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define rep(i,a,n) for(int i=a;i<=n;++i)
#define per(i,n,a) for(int i=n;i>=a;--i)
#define endl '\n'
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef pair<ll,ll> PII;
const int maxn = 1e6+200;
const int inf=0x3f3f3f3f;
const double eps = 1e-7;
const double pi=acos(-1.0);
const int mod = 1e9+7;
inline int lowbit(int x){return x&(-x);}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
void ex_gcd(ll a,ll b,ll &d,ll &x,ll &y){if(!b){d=a,x=1,y=0;}else{ex_gcd(b,a%b,d,y,x);y-=x*(a/b);}}//x=(x%(b/d)+(b/d))%(b/d);
inline ll qpow(ll a,ll b,ll MOD=mod){ll res=1;a%=MOD;while(b>0){if(b&1)res=res*a%MOD;a=a*a%MOD;b>>=1;}return res;}
inline ll inv(ll x,ll p){return qpow(x,p-2,p);}
inline ll Jos(ll n,ll k,ll s=1){ll res=0;rep(i,1,n+1) res=(res+k)%i;return (res+s)%n;}
inline ll read(){ ll f = 1; ll x = 0;char ch = getchar();while(ch>'9'||ch<'0') {if(ch=='-') f=-1; ch = getchar();}while(ch>='0'&&ch<='9') x = (x<<3) + (x<<1) + ch - '0', ch = getchar();return x*f; }
int dir[4][2] = { {1,0}, {-1,0},{0,1},{0,-1} }; ll a[maxn];
ll sum[maxn]; int main()
{
int kase;
cin>>kase;
while(kase--)
{
ll n = read();
map<ll,ll> Map;
rep(i,1,n) a[i] = read();
int flag = 0;
rep(i,1,n)
{
if(Map[a[i]])
{
flag = 1;
break;
}
Map[a[i]] = 1;
}
puts(flag?"YES":"NO");
}
return 0;
}

C. Engineer Artem

题意:给你一个二维矩阵,你可以对任意多个位置+1(每个位置只能加一次),让你输出一个相邻元素彼此不相同的矩阵。

思路:如果这题单靠模拟那就比较吃力了。首先看到题目的“+1”,+1最直接的好处就是可以划分奇偶性,这个时候就会想从奇偶的角度让相邻元素互异。所以构造方法可以是这样:



在打钩的地方让他变成奇数(原先是奇数的不变,偶数的话+1)。

其他地方变成偶数(原先是偶数的不变,奇数的话+1)。

就一定是一个最优策略了。

view code
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<map>
#include <queue>
#include<sstream>
#include <stack>
#include <set>
#include <bitset>
#include<vector>
#define FAST ios::sync_with_stdio(false)
#define abs(a) ((a)>=0?(a):-(a))
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mem(a,b) memset(a,b,sizeof(a))
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define rep(i,a,n) for(int i=a;i<=n;++i)
#define per(i,n,a) for(int i=n;i>=a;--i)
#define endl '\n'
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef pair<ll,ll> PII;
const int maxn = 1e5+200;
const int inf=0x3f3f3f3f;
const double eps = 1e-7;
const double pi=acos(-1.0);
const int mod = 1e9+7;
inline int lowbit(int x){return x&(-x);}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
void ex_gcd(ll a,ll b,ll &d,ll &x,ll &y){if(!b){d=a,x=1,y=0;}else{ex_gcd(b,a%b,d,y,x);y-=x*(a/b);}}//x=(x%(b/d)+(b/d))%(b/d);
inline ll qpow(ll a,ll b,ll MOD=mod){ll res=1;a%=MOD;while(b>0){if(b&1)res=res*a%MOD;a=a*a%MOD;b>>=1;}return res;}
inline ll inv(ll x,ll p){return qpow(x,p-2,p);}
inline ll Jos(ll n,ll k,ll s=1){ll res=0;rep(i,1,n+1) res=(res+k)%i;return (res+s)%n;}
inline ll read(){ ll f = 1; ll x = 0;char ch = getchar();while(ch>'9'||ch<'0') {if(ch=='-') f=-1; ch = getchar();}while(ch>='0'&&ch<='9') x = (x<<3) + (x<<1) + ch - '0', ch = getchar();return x*f; }
int dir[4][2] = { {1,0}, {-1,0},{0,1},{0,-1} }; ll n, m; int main()
{
int kase;
cin>>kase;
while(kase--)
{
n = read(), m = read();
rep(i,1,n)
{
rep(j,1,m)
{
ll x = read();
if((i+j)%2==0) cout<<x+(1 - x&1)<<' ';
else cout<<x+(x&1)<<' ';
}
cout<<endl;
}
}
return 0;
}

Codeforces Round #682 (Div. 2) ABC 题解的更多相关文章

  1. Codeforces Round #312 (Div. 2) ABC题解

    [比赛链接]click here~~ A. Lala Land and Apple Trees: [题意]: AMR住在拉拉土地. 拉拉土地是一个很漂亮的国家,位于坐标线.拉拉土地是与著名的苹果树越来 ...

  2. # Codeforces Round #529(Div.3)个人题解

    Codeforces Round #529(Div.3)个人题解 前言: 闲来无事补了前天的cf,想着最近刷题有点点怠惰,就直接一场cf一场cf的刷算了,以后的题解也都会以每场的形式写出来 A. Re ...

  3. Codeforces Round #557 (Div. 1) 简要题解

    Codeforces Round #557 (Div. 1) 简要题解 codeforces A. Hide and Seek 枚举起始位置\(a\),如果\(a\)未在序列中出现,则对答案有\(2\ ...

  4. Codeforces Round #540 (Div. 3) 部分题解

    Codeforces Round #540 (Div. 3) 题目链接:https://codeforces.com/contest/1118 题目太多啦,解释题意都花很多时间...还有事情要做,就选 ...

  5. Codeforces Round #538 (Div. 2) (A-E题解)

    Codeforces Round #538 (Div. 2) 题目链接:https://codeforces.com/contest/1114 A. Got Any Grapes? 题意: 有三个人, ...

  6. Codeforces Round #531 (Div. 3) ABCDEF题解

    Codeforces Round #531 (Div. 3) 题目总链接:https://codeforces.com/contest/1102 A. Integer Sequence Dividin ...

  7. Codeforces Round #527 (Div. 3) ABCDEF题解

    Codeforces Round #527 (Div. 3) 题解 题目总链接:https://codeforces.com/contest/1092 A. Uniform String 题意: 输入 ...

  8. Codeforces Round #499 (Div. 1)部分题解(B,C,D)

    Codeforces Round #499 (Div. 1) 这场本来想和同学一起打\(\rm virtual\ contest\)的,结果有事耽搁了,之后又陆陆续续写了些,就综合起来发一篇题解. B ...

  9. Codeforces Round #366 (Div. 2) ABC

    Codeforces Round #366 (Div. 2) A I hate that I love that I hate it水题 #I hate that I love that I hate ...

  10. Codeforces Round #545 (Div. 1) 简要题解

    这里没有翻译 Codeforces Round #545 (Div. 1) T1 对于每行每列分别离散化,求出大于这个位置的数字的个数即可. # include <bits/stdc++.h&g ...

随机推荐

  1. 1779. 找到最近的有相同 X 或 Y 坐标的点

    1779. 找到最近的有相同 X 或 Y 坐标的点 class Solution { public int nearestValidPoint(int x, int y, int[][] points ...

  2. JVM 的组成

    JVM 的组成 JVM(Java Virtual Machine)是 Java 的核心组件,负责执行 Java 字节码程序.以下是 JVM 的主要组成部分: 1. 类加载子系统(Class Loade ...

  3. Vue(七)——事件处理

    前情提要: v-on--监听DOM事件,在触发时运行js代码 在内联语句处理器中访问原始的 DOM 事件.可以用特殊变量 $event 把它传入方法 示例: <div id="exam ...

  4. 36.7K star!拖拽构建AI流程,这个开源LLM应用框架绝了!

    36.7K star!拖拽构建AI流程,这个开源LLM应用框架绝了! 只需拖拽节点,5分钟搭建专属AI工作流! Flowise 是一款革命性的低代码LLM应用构建工具,开发者通过可视化拖拽界面,就能快 ...

  5. 【经验】Git|如何删除错误的commit?(存在大文件无法push的commit、不需要的commit等情况、清除所有commit的情况)

    2024/04/24说明:这篇暂时修改为粉丝可见,因为正在冲粉丝量,等到我弄完了粉丝量的要求,我就改回来!不方便看到全文的小伙伴不好意思!! 文章目录 情况一:尚未推送或无法推送 情况二:已经推送 情 ...

  6. 完整版QQ(腾讯)开放平台操作指南(包含:qq登录能力获取等等)

    之前我和大家提过,我要购买第三方的APP服务,就相当于有自己的APP了,现在APP对接上线之前需要做大量的准备工作,在此把步骤分享给大家,这样可以节省大家很多时间. 完整版QQ(腾讯)开放平台操作指南 ...

  7. 小程序自定义组件 - 插槽slot

    和 vue 的 slot 几乎是一模一样的. 这个学小程序就相当于复习了一把 vue, 还是很值的. 我们之前说组件是页面的一部分, 目的是为了代码复用, 作为组件封装者, 有时候需要设计一些让用户能 ...

  8. RISC-V指令:逻辑指令与移位指令

    本节将继续学习逻辑指令(and.or.xor)和移位指令(sll.srl.sra) 逻辑指令 从CPU芯片电路角度来看,其实CPU更擅长指令逻辑操作,如与.或.异或 RISC-V指令集中包含了三种逻辑 ...

  9. RPC实战与核心原理之路由策略

    路由策略:怎么让请求按照设定的规则发到不同的节点上 回顾 健康检测在 RPC 中的作用,简单来讲就是帮助调用方应用来管理所有服务提供方的连接,并动态维护每个连接的状态,方便服务调用方在每次发起请求的时 ...

  10. C#/.NET/.NET Core技术前沿周刊 | 第 38 期(2025年5.12-5.18)

    前言 C#/.NET/.NET Core技术前沿周刊,你的每周技术指南针!记录.追踪C#/.NET/.NET Core领域.生态的每周最新.最实用.最有价值的技术文章.社区动态.优质项目和学习资源等. ...