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. 【Android 逆向】【攻防世界】easyjni

    1. apk 安装到手机,提示需要输入flag 2. jadx打开apk public class MainActivity extends c { static { System.loadLibra ...

  2. 学习go语言编程之函数

    函数定义 函数的基本组成:关键字func,函数名,参数列表,返回值,函数体,返回语句. 示例如下: func Add(a int, b int) (ret int, err error) { if a ...

  3. Dubbo使用APISIX作为网关

    为什么使用网关 Dubbo服务本身没有暴露HTTP接口,客户端(如:Web,APP)无法直接调用其提供的方法. 而APISIX可以通过dubbo-proxy插件为Dubbo服务提供外部访问的HTTP接 ...

  4. 删除node_modules文件夹cmd指令 - 20201015

    方法 方法一: rm -rf /node_modules cmd原生命令.只要支持cmd就可以使用. 方法二: rmdir /s/q your_app_dir 原生node方法,redir为node删 ...

  5. E4X已经被废弃,各浏览器基本上不再支持它;

    E4X是一种在ECMAScript标准的基础上加入的动态XML支持的程序语言扩展. 到2019年,目前主流浏览器已经不太支持它了,一些版本的Firefox浏览器或许还可以使用,但它已经在主流浏览器的主 ...

  6. JVM-对象实例化

    JVM-对象实例化 1.创建对象的方式 new:最常见的方式.Xxx的静态方法,XxxBuilder/XxxFactory的静态方法 Class的newInstance方法:反射的方式,只能调用空参的 ...

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

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

  8. Java 韩顺平老师的课,记的(前6章)笔记

    https://www.bilibili.com/video/BV1fh411y7R8/?p=110&spm_id_from=333.880.my_history.page.click& ...

  9. clickhouse 安装启动报<Error> Application: DB::Exception: There is no profile 'default' in configuration file. 以及常见的错误的总结

    1.启动时报错<Error> Application: DB::Exception: There is no profile 'default' in configuration file ...

  10. Java MVC 模式

    MVC 模式 MVC 模式代表 Model-View-Controller(模型-视图-控制器) 模式.这种模式用于应用程序的分层开发. Model(模型) - 模型代表一个存取数据的对象或 JAVA ...