当前位置:网站首页>Codeforces Round #803 (Div. 2)(A~D)
Codeforces Round #803 (Div. 2)(A~D)
2022-07-02 13:56:00 【_ dawn°】
Rehabilitation failure xD
C It took a long time to work out the inscription, and then fst 了 , Laugh to death , If it weren't for the novice protection period of less than six times, the score would be lost hhhhhh
A. XOR Mixup

Give an array , One of these numbers is the exclusive or sum of other numbers , Output this number .
Ideas : One of them is the exclusive or sum of other numbers , That means the XOR sum of this array is 0, According to the nature of the xor , Any number can be used as the exclusive or sum of all other numbers , The answer is to output any number in the array .
AC Code:
#include <bits/stdc++.h>
typedef long long ll;
#define INF 0x3f3f3f3f
const int mod=1e9+7;
const int N=1e3+5;
int t,n;
int a[N];
int main(){
std::ios::sync_with_stdio(false);
std::cin.tie(0);
std::cout.tie(0);
std::cin>>t;
while(t--){
std::cin>>n;
for(int i=1;i<=n;i++){
std::cin>>a[i];
}
std::cout<<a[n]<<'\n';
}
return 0;
}B. Rising Sand

Give a series of sand piles , Define a sand pile too high : The height of this sand pile is greater than the sum of two adjacent piles . Give a k, It can be used for continuous k Heap operation , Every pile +1, Ask how many sand piles are too high after several operations .
Ideas : Classification of discussion :k by 1 when , Because we can operate any pile without affecting the adjacent height , We can make it as much as possible , That is, there is one in every pile ;k Not 1 when , Each modification will affect the adjacent height , Make its relative height constant , We can infer k>1 No matter how many times you modify it, it will have no effect on the too high number .
AC Code:
#include <bits/stdc++.h>
typedef long long ll;
#define INF 0x3f3f3f3f
const int mod=1e9+7;
const int N=2e5+5;
int t,n,k;
int a[N];
int main(){
std::ios::sync_with_stdio(false);
std::cin.tie(0);
std::cout.tie(0);
std::cin>>t;
while(t--){
std::cin>>n>>k;
int ans=0;
for(int i=1;i<=n;i++){
std::cin>>a[i];
}
if(k==1){
int res=n-2;
std::cout<<(res+1)/2<<'\n';
continue;
}
for(int i=2;i<n;i++){
if(a[i]>a[i+1]+a[i-1]) ans++;
}
std::cout<<ans<<'\n';
}
return 0;
}C. 3SUM Closure

Give an array , If the sum of any three numbers in the array exists in the array , So this array is 3SUM-closed Of . Now give the array , Judge whether it is 3SUM-closed.
Ideas : If there are three positive numbers or three negative numbers in the array at the same time , That will constantly increase or decrease the maximum and minimum values , disqualification ; When the conditions are met , We can regard more elements in the array as 0, Just enumerate directly in a limited number .
AC Code:
#include <bits/stdc++.h>
#define int long long
const int N=2e5+5;
int t,n;
int a[N];
std::vector<int>vec;
std::map<int,int>mp;
bool check(){
int len=vec.size();
for(int i=0;i<len;i++){
for(int j=i+1;j<len;j++){
for(int k=j+1;k<len;k++){
if(!mp[vec[i]+vec[j]+vec[k]]) return false;
}
}
}
return true;
}
signed main(){
std::ios::sync_with_stdio(false);
std::cin.tie(0);
std::cout.tie(0);
std::cin>>t;
while(t--){
std::cin>>n;
int l=0,s=0;
vec.clear();
mp.clear();
for(int i=1;i<=n;i++){
std::cin>>a[i];
if(a[i]!=0) vec.push_back(a[i]);
else{
if(!mp[0]) vec.push_back(a[i]);
}
mp[a[i]]++;
if(a[i]>0) l++;
if(a[i]<0) s++;
}
if(l>=3||s>=3){
std::cout<<"NO"<<'\n';
continue;
}
std::cout<<(check()?"YES":"NO")<<'\n';
}
return 0;
}os: Clams clams
D. Fixed Point Guessing

Give an arrangement of odd lengths , Exchange positions in pairs , At last, there must be an element that has not been exchanged , Every time you ask, you can get all the numbers in a section , stay 15 This number can be found in times of inquiry .
Ideas : We can know how many numbers are in the original range by asking , Because the first array must be 1~n array . Then these numbers have two possibilities , One is to exchange with the value of this interval , In either case, there is no exchange . If elements that are not exchanged are in this interval , Then the length of this interval must be odd , Otherwise, the interval without exchange must be in another interval , For such consideration , Use two points , Can be satisfied in 15 Get the answer within times of asking .
( Add "fflush(stdout) or cout.flush()" Is to empty the cache , Use it directly std::endl Emptying is the same )
AC Code:
#include <bits/stdc++.h>
typedef long long ll;
const int N=1e4+5;
int t,n;
int a[N];
void ask(int l,int r){
std::cout<<"? "<<l<<' '<<r<<std::endl;
for(int i=l;i<=r;i++){
std::cin>>a[i];
}
}
int main(){
std::ios::sync_with_stdio(false);
std::cin.tie(0);
std::cout.tie(0);
std::cin>>t;
while(t--){
std::cin>>n;
int l=1,r=n;
while(l<r){
int mid=l+r>>1;
ask(l,mid);
int cnt=0;
for(int i=l;i<=mid;i++){
cnt+=(a[i]>=l&&a[i]<=mid);
}
if(cnt&1) r=mid;
else l=mid+1;
}
std::cout<<"! "<<l<<std::endl;
}
return 0;
}os: Interactive questions are actually the same as ordinary questions , The form is relatively new hhh
If there is any mistake, please advise , thank you !
边栏推荐
- 【虹科技术分享】如何测试 DNS 服务器:DNS 性能和响应时间测试
- Qt如何设置固定大小
- Which do you choose between Alibaba P7 with an annual salary of 900000 and deputy department level cadres?
- P1908 逆序对
- On flow delivery between microservices
- c# 水晶报表打印
- Unity skframework framework (XII), score scoring module
- uniapp小程序 subPackages分包配置
- [document tree, setting] font becomes smaller
- [Blue Bridge Cup] children's worship circle
猜你喜欢

Qt新项目_MyNotepad++
![[true topic of the Blue Bridge Cup trials 43] scratch space flight children's programming explanation of the true topic of the Blue Bridge Cup trials](/img/42/21f6d0fdd159faa8b63713624c95a2.png)
[true topic of the Blue Bridge Cup trials 43] scratch space flight children's programming explanation of the true topic of the Blue Bridge Cup trials

Téléchargement par navigateur

Everyone believes that the one-stop credit platform makes the credit scenario "useful"

(POJ - 1984) navigation nightare (weighted and search set)

What are eNB, EPC and PGW?

Subcontracting configuration of uniapp applet subpackages

When tidb meets Flink: tidb efficiently enters the lake "new play" | tilaker team interview

Origin绘制热重TG和微分热重DTG曲线
![[技术发展-22]:网络与通信技术的应用与发展快速概览-2- 通信技术](/img/a7/44609a5acf25021f1fca566c3d8c90.png)
[技术发展-22]:网络与通信技术的应用与发展快速概览-2- 通信技术
随机推荐
MySQL45讲——学习极客时间MySQL实战45讲笔记—— 04 | 深入浅出索引(上)
Qt新项目_MyNotepad++
BeanUtils -- shallow copy -- example / principle
Which do you choose between Alibaba P7 with an annual salary of 900000 and deputy department level cadres?
2022 zero code / low code development white paper [produced by partner cloud] with download
SystemServer进程
selenium 在pycharm中安装selenium
D如何检查null
[youcans' image processing learning course] general contents
题解《子数整数》、《欢乐地跳》、《开灯》
P1347 排序(拓扑 + spfa判断环 or 拓扑[内判断环])
The second anniversary of the three winged bird: the wings are getting richer and the take-off is just around the corner
Student course selection information management system based on ssm+jsp framework [source code + database]
Qt入门-制作一个简易的计算器
Will your sleep service dream of the extra bookinfo on the service network
Quantum three body problem: Landau fall
[Unity]使用GB2312,打包后程序不正常解决方案
Dingtalk 发送消息
为什么switch 的default后面要跟break?
Dingtalk send message