当前位置:网站首页>Codeforces Round #803 (Div. 2)vp
Codeforces Round #803 (Div. 2)vp
2022-07-01 05:36:00 【Bzdhxs_nt】
A XOR Mixup
长度为 1 的数列中,有一个数是其他数 X O R XOR XOR 来, 问这个数是多少
随便输出数列中的一个数就行
Code
void solve(){
int n;cin>>n;
vector<int> a(n+1);
int ans = 0;
forr(i,1,n) cin >> a[i];
cout << a[1] << endl;
}
B Rising Sand
当 m = 1 时, 最大的数量就是 ( n − 1 ) / 2 (n-1)/2 (n−1)/2;
m > 1 时,最大数量就是原数列 t o o t a l l too\ tall too tall 的个数;
Code
void solve(){
int n,m;
cin>>n>>m;
vector<int> a(n+1);
forr(i,1,n) cin >> a[i];
if(m == 1){
int res = (n-1)/2;
cout << res << endl;
}
else{
int res = 0;
forr(i,2,n-1){
if(a[i] > a[i-1]+a[i+1]) res++;
}
cout << res << endl;
}
}
C 3SUM Closure
当正数个数或负数个数 >= 3 时,必定不符合条件,输出 no;
当0的个数大于0时,最多有一正一负且枚举1个0即可,否则输出 no;
故,满足条件的数组元素个数最多是4个 O ( n 3 ) O(n^3) O(n3) 枚举即可
Code
void solve(){
int n;
cin>>n;
map<int,int> mp;
vector<int>v;
int t = 0;
int a = 0, b = 0;
forr(i,1,n){
int x;cin>>x;
mp[x] = 1;
if(x>0)a++,v.push_back(x);
else if(x<0)b++,v.push_back(x);
else t++;
}
if(t) v.push_back(0);
if(a>=3||b>=3){
puts("no");
return;
}
forr(i,0,v.size()-1)
forr(j,i+1,v.size()-1)
forr(k,j+1,v.size()-1){
int g = 0;
if(mp[v[i]+v[j]+v[k]]){
g = 1;
}
if(!g){
puts("no");
return ;
}
}
puts("yes");
}
D Fixed Point Guessing
交互题
发现 l o g 1 e 4 ≈ 14 log^{1e4} ≈ 14 log1e4≈14 考虑二分答案
对于区间 [ l , r ] [l,r] [l,r] 内的数有两种情况
值在 [ l , r ] [l,r] [l,r]范围内或者不在
值在区间[l,r]范围内的数也有两种情况
一种是与[l,r]内的值 s w a p swap swap,因而成对存在
另一种是在原位置
故对于[l,r]
若在这个范围内的数的个数为偶数,说明都是进行了 s w a p swap swap 操作
那么答案一定不在这个区间里,二分搜另一个区间
Code
vector<int> ask1(int l,int r){
cout << '?' <<" " << l << " " << r << endl;
vector<int> v;
forr(i,1,r-l+1){
int x;
cin>>x;
v.push_back(x);
}
return v;
}
bool check(vector<int> x,int l, int r){
int cnt = 0;
for(auto i:x){
if(i >= l && i <= r) cnt++;
}
if(cnt%2==0) return 0;
return 1;
}
void solve(){
int n;
cin >> n;
int l = 1, r= n;
int res = 0;
while(l < r){
int mid = l + r >> 1;
int f = 0;
vector<int> b;
b = ask1(l,mid);
int t = check(b,l,mid);
if(t){
r = mid;
}
else{
l = mid + 1;
}
}
cout << '!' <<" " << l << endl;
}
边栏推荐
- Summary of spanner's paper
- 数据库连接池的简单实现
- A little assistant for teenagers' physiological health knowledge based on wechat applet (free source code + project introduction + operation introduction + operation screenshot + Thesis)
- 【考研高数 自用】高数第一章基础阶段思维导图
- CentOS 7 installed php7.0 using Yum or up2date
- 0xc000007b the application cannot start the solution normally (the pro test is valid)
- mysql 将毫秒数转为时间字符串
- Application of industrial conductive slip ring
- boot+jsp的高校社團管理系統(附源碼下載鏈接)
- ssm+mysql二手交易网站(论文+源码获取链接)
猜你喜欢

Summary of spanner's paper
![[excel] column operation, which performs specific column for data in a cell, such as text division by comma, colon, space, etc](/img/c8/e3e31ad9ef214d97228cb501dd752f.jpg)
[excel] column operation, which performs specific column for data in a cell, such as text division by comma, colon, space, etc

Application of industrial conductive slip ring

数据库连接池的简单实现

【知识点总结】卡方分布,t分布,F分布

Rainbond结合NeuVector实践容器安全管理

Mongodb学习篇:安装后的入门第一课

在Rainbond中一键部署高可用 EMQX 集群

2/15 (awk, awk conditions, awk processing design can perform additional tasks, and use awk array +for loop to realize advanced search)

In depth understanding of condition source code interpretation and analysis of concurrent programming
随机推荐
Introduction of 3D Modeling and Processing Software Liu Ligang, Chinese University of Science and Technology
MySQL converts milliseconds to time string
mysql 将毫秒数转为时间字符串
小程序常用组件小结
What can the points mall Games bring to businesses? How to build a points mall?
Understand several related problems in JVM - JVM memory layout, class loading mechanism, garbage collection
Set集合详细讲解
Flutter can refresh data every time the interface comes in
Using nocalhost to develop microservice application on rainbow
数据治理:元数据管理实施(第四篇)
What is the at instruction set often used in the development of IOT devices?
Memtable for leveldb source code analysis
Ebpf cilium practice (2) - underlying network observability
boot+jsp的高校社团管理系统(附源码下载链接)
SSGSSRCSR区别
Leetcode top 100 question 2 Add two numbers
Set集合詳細講解
实战:redux的基本使用
HDU - 1069 Monkey and Banana(DP+LIS)
云原生存储解决方案Rook-Ceph与Rainbond结合的实践