CF1438A Specific Tastes of Andre

洛谷传送门

CF1438A


代码(全铺成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

洛谷传送门

CF1438B


分析

如果不存在两个数相同,那么就不可能产生进位,相加之后也不一样。

如果存在两个数相同,那答案就是这两个数所在的区间 \([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

洛谷传送门

CF1438C


分析

直接对矩阵黑白染色,黑色放奇数,白色放偶数即可

反正考场上没想到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

洛谷传送门

CF1438D


分析

有一些性质:异或前后异或和不变;如果有两个数 \(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

洛谷传送门

CF1438E


分析

考虑 \(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

洛谷传送门

CF1438F


分析

如果把这种题放考场可能还是不会做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)的更多相关文章

  1. Codeforces Round #682 (Div. 2)【ABCD】

    比赛链接:https://codeforces.com/contest/1438 A. Specific Tastes of Andre 题意 构造一个任意连续子数组元素之和为子数组长度倍数的数组. ...

  2. Codeforces Round #682 (Div. 2) C. Engineer Artem (构造)

    题意:给你一个\(n\)x\(m\)的矩阵,你可以任意位置的元素+1,只能加一次,问你如何使得任意位置的元素不等于它四周的值.输出操作后的矩阵. 题解:构造,矩阵中某两个下标的和的奇偶性一定和四周的都 ...

  3. Codeforces Round #682 (Div. 2) B. Valerii Against Everyone (思维)

    题意:给你一组数\(b\),对于每个\(b_i\),相对应的\(a_i=2^{b_i}\),问你是否能找出两个不相交的区间,使得两个区间的\(a_i\)的元素和相等. 题解:对于任意一个\(2^k\) ...

  4. 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 ...

  5. Codeforces Round #354 (Div. 2) ABCD

    Codeforces Round #354 (Div. 2) Problems     # Name     A Nicholas and Permutation standard input/out ...

  6. Codeforces Round #368 (Div. 2)

    直达–>Codeforces Round #368 (Div. 2) A Brain’s Photos 给你一个NxM的矩阵,一个字母代表一种颜色,如果有”C”,”M”,”Y”三种中任意一种就输 ...

  7. cf之路,1,Codeforces Round #345 (Div. 2)

     cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅.....   ...

  8. Codeforces Round #279 (Div. 2) ABCDE

    Codeforces Round #279 (Div. 2) 做得我都变绿了! Problems     # Name     A Team Olympiad standard input/outpu ...

  9. 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 ...

  10. 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 ...

随机推荐

  1. C++的strcat实现

    #include <iostream> #pragma warning(disable:4996); using namespace std; char* t = (char*)mallo ...

  2. 以二进制文件安装K8S之部署etcd高可用集群

    概述 前提条件:已经准备好CA根证书(etcd在制作CA证书时需要CA根证书),并且把CA根证书文件ca.key和ca.crt拷贝到3个etcd节点的/etc/kubernetes/pki目录下. 3 ...

  3. Hi3516开发笔记(八):Hi3516虚拟机交叉开发环境搭建之配置QtCreator开发交叉编译环境

    海思开发专栏 上一篇:<Hi3516开发笔记(七):Hi3516虚拟机交叉开发环境搭建之交叉编译Qt>下一篇:<Hi3516开发笔记(九):在QtCreator开发环境中引入海思sd ...

  4. instance must be started before calling this method

    解决方法 检查zk的连接数: 端口号: 数据库连接配置: zk的连接配置: 如果都没有问题,就重启容器.

  5. python部署-nginx部署带docker的https请求

    使用带docker的服务器配置https需要两层web服务器 首先例如使用https://www.Se7eN_HOU.com进行首页访问,首先会先进入到主服务器里面,经过主服务器的Nginx Web服 ...

  6. WPF性能优化:性能分析工具

    在硬件性能不断提升的现在,软件性能依旧是开发人员关注的重点.不同类型的程序关注的具体性能指标有所不同,服务器程序注重吞吐量,游戏引擎追求渲染效率,桌面程序则关注内存消耗以及界面加载效率和流畅性.当我们 ...

  7. canal实现mysql跨机房备份

    背景介绍 跨机房数据库数据备份 数据库增量异构系统分发(cache,mq等) 数据内容聚合分析组件 摘录作者的描述 原理图 canal 模拟 MySQL slave 的交互协议,伪装自己为 MySQL ...

  8. 【Azure Redis】Azure Redis添加了内部虚拟网络后,其他区域的主机通过虚拟网络对等互连访问失败

    问题描述 跨区域无法访问Azure Redis服务, Redis 启用了Network并设置在一个VNET中,现在客户端部署在另一个区域数据中心中,两个数据中心区域使用VNET Peer(对等互连)访 ...

  9. .NET 全能 Cron 表达式解析库(支持 Cron 所有特性)

    前言 今天大姚给大家分享一个.NET 全能 Cron 表达式解析类库,支持 Cron 所有特性:TimeCrontab. Cron表达式介绍 Cron表达式是一种用于配置定时任务的时间表达式.它由一系 ...

  10. 线段树-多个懒标记pushdown

    P3373 [模板]线段树 2 这里需要用到两个懒标记,一个懒标记为add,记录加,另一个懒标记为mul,记录乘. 我们需要规定一个优先级,然后考虑如何将懒标记下传. 这里无非有两种顺序,一种是先乘后 ...