当前位置:网站首页>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;
}
边栏推荐
- Speed regulation and stroke control based on Ti drv8424 driving stepper motor
- JDBC常见面试题
- 数字金额加逗号;js给数字加三位一逗号间隔的两种方法;js数据格式化
- Using nocalhost to develop microservice application on rainbow
- Unity项目心得总结
- 2/15 (awk, awk conditions, awk processing design can perform additional tasks, and use awk array +for loop to realize advanced search)
- 2022.6.30-----leetcode. one thousand one hundred and seventy-five
- [ffmpeg] [reprint] image mosaic: picture in picture with wheat
- busybox生成的东西
- Basic electrician knowledge 100 questions
猜你喜欢

【考研高数 武忠祥+880版 自用】高数第二章基础阶段思维导图

eBPF Cilium实战(2) - 底层网络可观测性

HCM 初学 ( 一 ) - 简介

Thread process foundation of JUC
![[QT] QT after addition, subtraction, multiplication and division, two decimal places are reserved](/img/30/c802ae9b65601832bf52e760e9962d.png)
[QT] QT after addition, subtraction, multiplication and division, two decimal places are reserved

Speed regulation and stroke control based on Ti drv8424 driving stepper motor

导数的左右极限和左右导数的辨析

In depth understanding of condition source code interpretation and analysis of concurrent programming

Learn the customization and testing of fpga---ram IP from the bottom structure

Simple implementation of database connection pool
随机推荐
Application of industrial conductive slip ring
First defined here occurs during QT compilation. Causes and Solutions
Ssgssrcsr differences
C WPF uses dockpanel to realize screenshot box
Memtable for leveldb source code analysis
数据治理:数据治理管理(第五篇)
Using nocalhost to develop microservice application on rainbow
RecycleView的一些使用
Things generated by busybox
[ffmpeg] [reprint] image mosaic: picture in picture with wheat
Mathematical knowledge: finding the number of divisors
Summary of common components of applet
Trust guessing numbers game
rust猜数字游戏
HCM 初学 ( 四 ) - 时间
Rust hello-word
busybox生成的东西
LRU cache for leveldb source code analysis
Ssm+mysql second-hand trading website (thesis + source code access link)
Rainbow combines neuvector to practice container safety management