Codeforces Round #682 (Div. 2)
CF1438A Specific Tastes of Andre
代码(全铺成1就可以了)
#include <cstdio>
#include <cctype>
#define rr register
using namespace std;
inline signed iut(){
rr int ans=0; rr char c=getchar();
while (!isdigit(c)) c=getchar();
while (isdigit(c)) ans=(ans<<3)+(ans<<1)+(c^48),c=getchar();
return ans;
}
inline void print(int ans){
if (ans>9) print(ans/10);
putchar(ans%10+48);
}
signed main(){
for (rr int T=iut();T;--T,putchar(10)){
for (rr int n=iut();n;--n)
putchar(49),putchar(32);
}
return 0;
}
CF1438B Valerii Against Everyone
分析
如果不存在两个数相同,那么就不可能产生进位,相加之后也不一样。
如果存在两个数相同,那答案就是这两个数所在的区间 \([i,i]\) 和 \([j,j]\)
代码
#include <cstdio>
#include <cctype>
#include <map>
#define rr register
using namespace std;
int n,flag; map<int,bool>uk;
inline signed iut(){
rr int ans=0; rr char c=getchar();
while (!isdigit(c)) c=getchar();
while (isdigit(c)) ans=(ans<<3)+(ans<<1)+(c^48),c=getchar();
return ans;
}
inline void print(int ans){
if (ans>9) print(ans/10);
putchar(ans%10+48);
}
signed main(){
for (rr int T=iut();T;--T){
n=iut(),uk.clear(),flag=0;
for (rr int i=1,x;i<=n;++i)
if (uk[x=iut()]) {
if (!flag) puts("YES");
flag=1;
}else uk[x]=1;
if (!flag) puts("NO");
}
return 0;
}
CF1438C Engineer Artem
分析
直接对矩阵黑白染色,黑色放奇数,白色放偶数即可
反正考场上没想到QAQ
代码
#include <iostream>
using namespace std;
int T,n,m;
int main(){
ios::sync_with_stdio(0);
for (cin>>T;T;--T){
cin>>n>>m;
for (int i=1;i<=n;++i,cout<<endl)
for (int j=1;j<=m;++j){
int x; cin>>x;
if ((i^j^x)&1) cout<<x+1<<" ";
else cout<<x<<" ";
}
}
return 0;
}
CF1438D Powerful Ksenia
分析
有一些性质:异或前后异或和不变;如果有两个数 \(a_j,a_k\) 相同,那么 \(a_i,a_j,a_k\) 异或之后全部变成 \(a_i\)。
那么给两两配对,如果序列长度为奇数意味着可以先用 \(\frac{n-1}{2}\) 次将配对的数变为相同的数,
再用 \(\frac{n-1}{2}\) 次将所有数变相同。
否则序列长度为偶数有解当且仅当所有数异或和为0,这样只对前 \(n-1\) 个数操作第 \(n\) 个数会自动相同
代码
#include <iostream>
using namespace std;
int n,sum;
int main(){
ios::sync_with_stdio(0);
cin>>n;
for (int i=1;i<=n;++i){
int x; cin>>x,sum^=x;
}
if (!(n&1)&&sum) cout<<"NO";
else{
cout<<"YES"<<endl<<n-2+(n&1)<<endl;
for (int i=2;i<n;i+=2) cout<<1<<" "<<i<<" "<<i+1<<endl;
for (int i=2;i<n;i+=2) cout<<1<<" "<<i<<" "<<i+1<<endl;
}
return 0;
}
CF1438E Yurii Can Do Everything
分析
考虑 \(O(n^2)\) (bushi
因为总和肯定会增大,所以考虑以左端点为基准或者以右端点为基准,
当增大到 \(2^{mx[i]+1}\) 时异或值一定不相等,退出循环。
这样看时间貌似是差不多的,但是如果考虑枚举 \(mx[i]\) 的话,每个位置最多被访问两次。
所以时间复杂度为 \(O(n\log \max\{a_i\})\)
代码
#include <iostream>
#include <set>
using namespace std;
const int N=34011;
int n,mx[N],a[N*6],bit[N*6]; set<pair<int,int> >ans;
int main(){
ios::sync_with_stdio(0);
cin>>n;
for (int i=0;i<15;++i)
for (int j=(1<<i);j<(1<<(i+1));++j)
mx[j]=i+1;
for (int i=1;i<=n;++i){
cin>>a[i];
if (!(a[i]>>15)) bit[i]=mx[a[i]];
else bit[i]=15+mx[a[i]>>15];
}
for (int i=1;i<n-1;++i){
int sum=a[i+1];
for (int j=i+2;j<=n;++j){
if (sum>=(1<<bit[i])) break;
if ((a[i]^a[j])==sum) ans.insert(make_pair(i,j));
sum+=a[j];
}
}
for (int j=n;j>2;--j){
int sum=a[j-1];
for (int i=j-2;i;--i){
if (sum>=(1<<bit[j])) break;
if ((a[i]^a[j])==sum) ans.insert(make_pair(i,j));
sum+=a[i];
}
}
cout<<ans.size();
return 0;
}
CF1438F Olha and Igor
分析
如果把这种题放考场可能还是不会做QWQ
这道题最妙的就是用420次随机三个点,
就可以知道根节点的两个子节点。
然后再用 \(n\) 次判断根节点即可,证明也不会。
反正随机题都挺玄学的
代码
#include <iostream>
#include <algorithm>
using namespace std;
const int N=300011;
int n,h,rk[N],c[N];
bool cmp(int x,int y){return c[x]>c[y];}
int main(){
ios::sync_with_stdio(0);
cin>>h,n=(1<<h)-1,srand(33333331);
for (int i=1;i<=n;++i) rk[i]=i;
for (int i=1;i<421;++i){
int x=(rand()*rand()+rand())%n+1,y=(rand()*rand()+rand())%n+1,rt=(rand()*rand()+rand())%n+1;
while (x==y) y=(rand()*rand()+rand())%n+1;
while (rt==x||rt==y) rt=(rand()*rand()+rand())%n+1;
cout<<"? "<<x<<" "<<y<<" "<<rt<<endl;
cin>>x; ++c[x];
}
sort(rk+1,rk+1+n,cmp);
for (int i=1;i<=n;++i)
if (i!=rk[1]&&i!=rk[2]){
cout<<"? "<<rk[1]<<" "<<rk[2]<<" "<<i<<endl;
int x; cin>>x;
if (x==i){
cout<<"! "<<x<<endl;
return 0;
}
}
return 0;
}
Codeforces Round #682 (Div. 2)的更多相关文章
- Codeforces Round #682 (Div. 2)【ABCD】
比赛链接:https://codeforces.com/contest/1438 A. Specific Tastes of Andre 题意 构造一个任意连续子数组元素之和为子数组长度倍数的数组. ...
- Codeforces Round #682 (Div. 2) C. Engineer Artem (构造)
题意:给你一个\(n\)x\(m\)的矩阵,你可以任意位置的元素+1,只能加一次,问你如何使得任意位置的元素不等于它四周的值.输出操作后的矩阵. 题解:构造,矩阵中某两个下标的和的奇偶性一定和四周的都 ...
- Codeforces Round #682 (Div. 2) B. Valerii Against Everyone (思维)
题意:给你一组数\(b\),对于每个\(b_i\),相对应的\(a_i=2^{b_i}\),问你是否能找出两个不相交的区间,使得两个区间的\(a_i\)的元素和相等. 题解:对于任意一个\(2^k\) ...
- 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 ...
- Codeforces Round #354 (Div. 2) ABCD
Codeforces Round #354 (Div. 2) Problems # Name A Nicholas and Permutation standard input/out ...
- Codeforces Round #368 (Div. 2)
直达–>Codeforces Round #368 (Div. 2) A Brain’s Photos 给你一个NxM的矩阵,一个字母代表一种颜色,如果有”C”,”M”,”Y”三种中任意一种就输 ...
- cf之路,1,Codeforces Round #345 (Div. 2)
cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅..... ...
- Codeforces Round #279 (Div. 2) ABCDE
Codeforces Round #279 (Div. 2) 做得我都变绿了! Problems # Name A Team Olympiad standard input/outpu ...
- Codeforces Round #262 (Div. 2) 1003
Codeforces Round #262 (Div. 2) 1003 C. Present time limit per test 2 seconds memory limit per test 2 ...
- Codeforces Round #262 (Div. 2) 1004
Codeforces Round #262 (Div. 2) 1004 D. Little Victor and Set time limit per test 1 second memory lim ...
随机推荐
- redis7源码分析:redis 单线程模型解析,一条get命令执行流程
有了下文的梳理后 redis 启动流程 再来解析redis 在单线程模式下解析并处理客户端发来的命令 1. 当 client fd 可读时,会回调readQueryFromClient函数 void ...
- 混合类Mixins介绍
介绍 混合类是封装了一些通用行为的基类,旨在重用代码.通常,混合类本身并没有什么用,仅扩展这种类也行不通 因为在大多数情况下,它都依赖于其它类中定义的方法和属性.通过多继承,可将混合类与其它类一起使用 ...
- Advanced .Net Debugging 2:CLR基础
一.简介 这是2024新年后我的第一篇文章,也是我的<Advanced .Net Debugging>这个系列的第二篇文章.这篇文章告诉我们为了进行有效的程序调试,我们需要掌握哪些知识.言 ...
- 【Azure Redis 缓存】Azure Redis Cluster 在增加分片数时失败分析
问题描述 Azure Redis Cluster 在增加分片数时失败,错误消息为: ResponseBody: { "error": { "details": ...
- 快速带你入门css
css复习笔记 1. css样式值 1.1 文字样式 1 p{ 2 font-size: 30px;/*设置文字大小*/ 3 font-weight: bold;/*文字加粗*/ 4 font-sty ...
- centos 目录磁盘使用情况
最简单的查看方法可以使用ls -ll.ls-lh命令进行查看,当使用ls -ll,会显示成字节大小,而ls- lh会以KB.MB等为单位进行显示,这样比较直观一些. 通过命令du -h –max- ...
- org.jetbrains.idea.maven - com.google.inject.CreationException: Unable to create injector, see the following errors-导入maven项目报错
一.问题由来 最近准备更换Java开发工具,以前是使用Eclipse,现在准备换成号称Java开发神器的IntelliJ IDEA .在同事那里找到安装包后, 安装,导入需要的文件等等,一切都进行得很 ...
- dist目录打war包命令 jar -cvf yourName_web.war *
进入dist目录 "build:war": "cd dist && jar -cvf ../yourName_web.war *",
- Go | Gin 解决跨域问题跨域配置
Go | Gin 解决跨域问题跨域配置 目录 一.关于跨域解决方案 二.使用步骤 1. 编写一个中间件 2. 使用 3. 注意事项 一.关于跨域解决方案 关于跨域的解决方法,大部分可以分为 2 种 n ...
- javascript import maps 特性现已被全部主流浏览器支持
值得庆祝 Import maps 特性现在可以在全部三个主要浏览器内使用 现在主流现代web 应用 引入和利用javascript 是通过 Es module 模块实现. 在开发javascript上 ...