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. 函数组件的声明方式及差异+React.memo和userCallback区别

    1.函数组件的声明方式及差异 普通函数声明 箭头函数声明 使用React.FC类型(TypeScript专用) interface Props { content: string } // 写法一 c ...

  2. 安装debian12和win11双系统

    安装环境:微星主板,AMD CPU 5700G 使用rfues制作分别制作win启动盘(可以在i tell you下载)和debian12(清华源下载较快)启动盘 先安装windows: 主板设置U盘 ...

  3. hadoop部署安装(三)zookeeper+yarn

    1. 配置zookeeper 3.1 解压存放指定目录 [root@bogon src]# tar xf zookeeper-3.4.10.tar.gz [root@bogon src]# mv zo ...

  4. EF ——left join

    如何在EF中实现left join(左联接)查询_ var TestList = from p in context.PersonalInformation join d in context.Dep ...

  5. Java编程--单例(Singleton)设计模式

    单例设计模式 一个类只有一个实例,根据创建的时机又分为懒汉式和饿汉式,它们的区别主要体现在实例的创建时机和线程安全性上. 饿汉式(Eager Initialization): 特点: 在类加载时就创建 ...

  6. Java 线程的常用操作方法

    目录 线程命名和取得 线程的休眠 线程优先级(priority) 线程命名和取得 如果想要进行线程名称的操作,可以使用Thread类的如下方法: 构造方法:public Thread(Runnable ...

  7. 【代码】Processing笔触手写板笔刷代码合集(包含流速、毛笔笔触、压感笔触等多种)

    代码来源于openprocessing,考虑到国内不是很好访问,我把我找到的比较好的搬运过来! @ 目录 合集1 笔触4(流速笔触,速写) 笔触5(流速笔触,晕染) 笔触6(流速笔触,毛笔) 合集2 ...

  8. 【MOOC】华中科技大学操作系统慕课答案-第4~6章+第7章单元测试

    文章目录 单选 填空 判断 第七章答案 单选 1 ‎关于进程错误的说法是 . A. 进程的运行全过程不可重现. √B. 一个程序只能生成一个进程. C. 进程具有异步性. D. 多个并发进程共享CPU ...

  9. C#网络编程(三)----HTTP协议

    HTTP协议 HTTP(超文本传输协议),属于应用层协议.基于TCP连接实现.但通信方向始终由客户端发起(HTTP/2之后已修改). 维度 TCP/IP协议族(传输层/TCP) HTTP协议(应用层) ...

  10. C# unsafe 快速复制数组

    (1) /// <summary> /// 复制内存 /// </summary> /// <param name="dest">目标指针位置& ...