当前位置:网站首页>Codeforces Round #803 (Div. 2)vp
Codeforces Round #803 (Div. 2)vp
2022-07-01 05:45:00 【Bzdhxs_ nt】
A XOR Mixup
The length is 1 In the sequence of , One number is another number X O R XOR XOR Come on , What is this number
Just output any number in the sequence
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
When m = 1 when , The largest number is ( n − 1 ) / 2 (n-1)/2 (n−1)/2;
m > 1 when , The maximum number is the original sequence t o o t a l l too\ tall too tall The number of ;
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
When there are positive numbers or negative numbers >= 3 when , Must not meet the conditions , Output no;
When 0 The number of is greater than 0 when , There is at most one positive and one negative and enumeration 1 individual 0 that will do , Otherwise output no;
so , The maximum number of array elements that meet the conditions is 4 individual O ( n 3 ) O(n^3) O(n3) Enumeration is enough
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
Interactive questions
Find out l o g 1 e 4 ≈ 14 log^{1e4} ≈ 14 log1e4≈14 Think about the dichotomy
For interval [ l , r ] [l,r] [l,r] There are two cases of numbers in
Values in [ l , r ] [l,r] [l,r] Within or out of
The value is in the range [l,r] There are also two cases of numbers in the range
One is with [l,r] Internal value s w a p swap swap, So they exist in pairs
The other is in the original position
So for [l,r]
If number of the numbers in this range is even , The explanation is that s w a p swap swap operation
Then the answer must not be in this range , Binary search another interval
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;
}
边栏推荐
- Qt编写自定义控件-自绘电池
- 从底层结构开始学习FPGA----RAM IP的定制与测试
- 输入一个表达式(用字符串表示),求这个表达式的值。
- Common solutions for mobile terminals
- LeetCode 最大矩形,最大正方形系列 84. 85. 221. 1277. 1725. (单调栈,动态规划)
- vsCode函数注解/文件头部注解快捷键
- Advanced cross platform application development (III): online resource upgrade / hot update with uni app
- OpenGL ES: (5) OpenGL的基本概念、OpenGL ES 在屏幕产生图片的过程、OpenGL管线(pipeline)
- A little assistant for teenagers' physiological health knowledge based on wechat applet (free source code + project introduction + operation introduction + operation screenshot + Thesis)
- Web Security (IX) what is JWT?
猜你喜欢
![[medical segmentation] u2net](/img/b3/b1d188216310fe1217e360ac56af3b.jpg)
[medical segmentation] u2net

喊我们大学生个人云服务特供商

Mongodb學習篇:安裝後的入門第一課

How to create a progress bar that changes color according to progress
![Fiber Bragg grating (FBG) notes [1]: waveguide structure and Bragg wavelength derivation](/img/83/97c0c6e23cbb7b4c2b630c217c5206.jpg)
Fiber Bragg grating (FBG) notes [1]: waveguide structure and Bragg wavelength derivation

Leetcode Max rectangle, Max square series 84 85. 221. 1277. 1725. (monotonic stack, dynamic programming)

Summary of common components of applet

千万不要把笔记视频乱放!

What is the at instruction set often used in the development of IOT devices?

从诺奖知“边缘计算”的未来!
随机推荐
Educational administration management system of SSM (free source code)
Simple implementation of database connection pool
Typeorm framework
Looking for high school student developers with similar interests
Continue to learn MySQL
json数据比较器
Leetcode Max rectangle, Max square series 84 85. 221. 1277. 1725. (monotonic stack, dynamic programming)
rust猜数字游戏
HCM 初学 ( 三 ) - 快速输入PA70、PA71 浏览员工信息PA10
JDBC常见面试题
excel高级绘图技巧100讲(一)-用甘特图来展示项目进度情况
idea启动查看项目端口
POL8901 LVDS转MIPI DSI 支持旋转图像处理芯片
关于一道01背包问题的·拓展题的思考
vsCode函数注解/文件头部注解快捷键
Flowable source code comment (XXXIX) task listener
Deeply understand the underlying implementation principle of countdownlatch in concurrent programming
What is the at instruction set often used in the development of IOT devices?
[excel] column operation, which performs specific column for data in a cell, such as text division by comma, colon, space, etc
HCM 初学 ( 一 ) - 简介