当前位置:网站首页>Codeforces Round #803 (Div. 2)
Codeforces Round #803 (Div. 2)
2022-06-29 12:13:00 【Zqchang】
After half a year , Return cf, In the first game, it was a smash
A
A. XOR Mixup
I can only say that it is very kind , Water problem
Is oneself dev Another card bug 了 ,tnnd
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <map>
#include <string>
#include <cstring>
#include <cmath>
#include <stack>
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fast ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define sc(a) scanf("%lld",&a)
#define pf(a) printf("%d",a)
#define endl "\n"
#define int long long
#define mem(a,b) memset(a,b,sizeof a)
#define ull unsigned long long
#define INF 0x3f3f3f3f3f3f3f3f
#define inf 0x3f3f3f3f
#define rep(i,a,b) for(auto i=a;i<=b;++i)
#define bep(i,a,b) for(auto i=a;i>=b;--i)
#define LL long long
#define lowbit(x) x&(-x)
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define PI acos(-1)
#define pb push_back
#define x first
#define y second
const double eps = 1e-6;
const int mod = 998244353;
const int MOD = 1e9 + 7;
const int N = 110;
int a[N];
int t, n;
signed main()
{
fast;
cin >> t;
while(t--)
{
cin >> n;
for(int i=1; i<=n; i++) cin >> a[i];
int res;
for(int i=1; i<=n; i++)
{
res = 0;
for(int j=1; j<=n; j++)
{
if(i == j) continue;
res ^= a[j];
}
// puts("111");
if(res == a[i])
{
cout << res << endl;
break;
}
// else puts("!!");
}
}
return 0;
}
B. Rising Sand
After reading , It feels very nt, Then I finished writing and handed it in once ,wa, Then I found that I forgot the special judgment k=1
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <map>
#include <string>
#include <cstring>
#include <cmath>
#include <stack>
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fast ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define sc(a) scanf("%lld",&a)
#define pf(a) printf("%d",a)
#define endl "\n"
#define int long long
#define mem(a,b) memset(a,b,sizeof a)
#define ull unsigned long long
#define INF 0x3f3f3f3f3f3f3f3f
#define inf 0x3f3f3f3f
#define rep(i,a,b) for(auto i=a;i<=b;++i)
#define bep(i,a,b) for(auto i=a;i>=b;--i)
#define lowbit(x) x&(-x)
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define PI acos(-1)
#define pb push_back
#define x first
#define y second
const double eps = 1e-6;
const int mod = 998244353;
const int MOD = 1e9 + 7;
const int N = 2e5 + 10;
int t, n, m;
int a[N];
signed main()
{
fast;
cin >> t;
while(t--)
{
cin >> n >> m;
for(int i=1; i<=n; i++) cin >> a[i];
if(m == 1)
{
cout << (n - 1) / 2 << endl;
continue;
}
int res = 0;
for(int i=2; i<n; i++)
{
if(a[i] > a[i-1] + a[i+1]) res ++;
}
cout << res << endl;
}
return 0;
}
C. 3SUM Closure
It's interesting , That is to say , I have an array , It's optional ijk Three subscripts , Their array pairs use the sum of numbers , It should still be in the array , Is a good array , Then I ask you if the array is , At first I thought , Make a sequence , Look at the sum of the first three numbers If the sum of the last three numbers is all in the array , Then I found something wrong , Because the beginning and the end may not be equal , There's a similar one -2, -1, 1, 1 This situation is actually NO, Will be output YES, Just go out and do the two
That is to say
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <map>
#include <string>
#include <cstring>
#include <cmath>
#include <stack>
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fast ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define sc(a) scanf("%lld",&a)
#define pf(a) printf("%d",a)
#define endl "\n"
#define int long long
#define mem(a,b) memset(a,b,sizeof a)
#define ull unsigned long long
#define INF 0x3f3f3f3f3f3f3f3f
#define inf 0x3f3f3f3f
#define rep(i,a,b) for(auto i=a;i<=b;++i)
#define bep(i,a,b) for(auto i=a;i>=b;--i)
#define lowbit(x) x&(-x)
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define PI acos(-1)
#define pb push_back
#define x first
#define y second
const double eps = 1e-6;
const int mod = 998244353;
const int MOD = 1e9 + 7;
const int N = 2e5 + 10;
int t, n, m;
int a[N];
set<int> s;
signed main()
{
fast;
cin >> t;
while(t--)
{
s.clear();
cin >> n;
int num = 0;
// bool flag =
for(int i=1; i<=n; i++)
{
cin >> a[i];
s.insert(a[i]);
if(a[i] != 0) num ++;
}
if(n == 4)
{
bool flag = 0;
for(int i=1; i<=4; i++)
{
for(int j=i+1; j<=4; j++)
{
for(int k=j+1;k<=4; k++)
{
int a1 = a[i] + a[j] + a[k];
if(!s.count(a1))
{
cout << "NO" << endl;
flag = 1;
break;
}
}
if(flag) break;
}
if(flag) break;
}
if(!flag) cout << "YES" << endl;
continue;
}
sort(a + 1, a + 1 + n);
int a1 = a[1] + a[2] + a[3];
int a2 = a[n] + a[n - 1] + a[n - 2];
if(s.count(a1) && s.count(a2))
{
if(num == 2)
{
if(a1 == -a2)
{
cout << "YES" << endl;
continue;
}
else
{
cout << "NO" << endl;
continue;
}
}
cout << "YES" << endl;// The beginning and the end may not be equal , There's a similar one -2, -1, 1, 1 This situation is actually NO
}
else cout << "NO" << endl;
}
return 0;
}
There is another way to start A Dropped , In fact, it is to find a rule
according to n by 3 and 4 When it comes to violent judgment
After that, the middle must be 0, Just looking for it doesn't mean 0 The number of num, Is full of 0 and num Less than 1 Sure ,num>2 no way ,num=2 When they are opposite to each other, they can
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <map>
#include <string>
#include <cstring>
#include <cmath>
#include <stack>
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fast ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define sc(a) scanf("%lld",&a)
#define pf(a) printf("%d",a)
#define endl "\n"
#define int long long
#define mem(a,b) memset(a,b,sizeof a)
#define ull unsigned long long
#define INF 0x3f3f3f3f3f3f3f3f
#define inf 0x3f3f3f3f
#define rep(i,a,b) for(auto i=a;i<=b;++i)
#define bep(i,a,b) for(auto i=a;i>=b;--i)
#define LL long long
#define lowbit(x) x&(-x)
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define PI acos(-1)
#define pb push_back
#define x first
#define y second
const double eps = 1e-6;
const int mod = 998244353;
const int MOD = 1e9 + 7;
const int N = 2e5 + 10;
int t, n, a[N];
set<int> s;
signed main()
{
cin >> t;
while(t--)
{
s.clear();
cin >> n;
int num = 0;
for(int i=1;i<=n; i++)
{
cin >> a[i];
if(a[i] != 0) num ++;
s.insert(a[i]);
}
if(n == 3)
{
int aa = a[1] + a[2] + a[3];
if(s.count(aa))
{
cout << "YES" << endl;
continue;
}
else
{
cout << "NO" << endl;
continue;
}
}
if(n == 4)
{
bool flag = 0;
for(int i=1; i<=4; i++)
{
for(int j=i+1; j<=4; j++)
{
for(int k=j+1;k<=4; k++)
{
int a1 = a[i] + a[j] + a[k];
if(!s.count(a1))
{
cout << "NO" << endl;
flag = 1;
break;
}
}
if(flag) break;
}
if(flag) break;
}
if(!flag) cout << "YES" << endl;
continue;
}
if(num > 2)
{
cout << "NO" << endl;
continue;
}
else if(num <= 1)
{
cout << "YES" << endl;
continue;
}
else
{
sort(a + 1, a + 1 + n);
if(a[1] == -a[n])
{
cout << "YES" << endl;
continue;
}
else
{
cout << "NO" << endl;
continue;
}
}
}
return 0;
}
D. Fixed Point Guessing
D. Fixed Point Guessing
An interactive question , Do it for the first time , A little new
It's not difficult to understand. , Give you an odd number , Then match the numbers from the inside , There is a single immobility , Other exchange locations , Then you can give an interval at a time , He gives you the result of sorting the original array , Ask no more than fifteen times , Ask what your individual number is , Two points plus discussion
Is the number of numbers that cannot be found in this interval each time , Then look at how many numbers there are in this interval , There are answers in odd numbers , Just keep two points
#include<map>
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<cstring>
#include<sstream>
#include<cmath>
#define up(i, x, y) for(int i = x; i <= y; i++)
#define down(i, x, y) for(int i = x; i >= y; i--)
#define maxn ((int)5e5 + 10)
#define INF 0x3f3f3f3f
typedef long long ll;
using namespace std;
vector<int> vec;
int main()
{
int T; cin >> T; while(T--)
{
int n; cin >> n;
int ans = -1;
int tim = 15;
int l = 1, r = n;
while(l < r)
{
int mid = (l + r) >> 1;
cout << "? " << l << " " << mid << endl;
cout.flush();
int num = 0;
for(int i = 0; i < mid - l + 1; ++i)
{
int x; cin >> x;
if(x < l || x > mid) num++;
}
if( (mid - l + 1 - num) & 1 ) r = mid;
else l = mid + 1;
}
std::cout << "? " << l << " " << l << std::endl;
int x; cin >> x;
cout << "! " << l << endl;
cout.flush();
}
}
边栏推荐
- 2022 construction worker civil engineering direction general foundation (construction worker) theoretical question bank simulation test platform operation
- When you are young, you should be awake to fight, and when you are young, you should have the courage to try
- 面试突击61:说一下MySQL事务隔离级别?
- Li Kou daily question - day 31 -1779 Find the nearest point with the same X or Y coordinate
- 服务数百万开发者,首届 Techo Day 腾讯技术开放日发布 7 款“轻量级”产品
- The blackened honeysnow ice city wants to grasp the hearts of consumers by marketing?
- 2022 Guangxi provincial safety officer C certificate examination questions and mock examination
- SOFARegistry 源码|数据同步模块解析
- Jerry's about TWS channel configuration [chapter]
- GBase8s数据库select有ORDER BY 子句6
猜你喜欢

谷粒商城项目

什么是外链和内链?

Numpy的ndarray数组基础

Pro test! Centos7 deploy PHP + spool

论文复现——AC-FPN:Attention-guided Context Feature Pyramid Network for Object Detection.

Unified exception reporting practice based on bytecode
![Jerry's about TWS channel configuration [chapter]](/img/2c/58a49dea7a7931c4d1f055548c2493.png)
Jerry's about TWS channel configuration [chapter]

The blackened honeysnow ice city wants to grasp the hearts of consumers by marketing?

黑化的蜜雪冰城,凭营销就想抓牢消费者的心?

大家有没有觉得学机械的人很可怕?
随机推荐
Win11 web version
GBase8s数据库select有ORDER BY 子句2
Oracle expands distributed cloud services to bring comprehensive public cloud services to more customers
年轻就要醒着拼,年轻就要勇于尝试
Helping the ultimate experience, best practice of volcano engine edge computing
启泰观察:职业精英创业必踩巨坑之 --- 学习效果坑
杰理之手动配对方式【篇】
Pytoch - distributed communication primitive (with source code)
保障饮用水安全!番禺沙湾水道水质在线监测系统通过验收
MMdet中的Resnet源码解读+Ghost模块
shell判断命令是否执行成功
基础类型变量声明
GBase8s数据库select有ORDER BY 子句1
易快报:我们用 Zadig 实现万次构建部署,聪明运维,释放开发生产力
When you are young, you should be awake to fight, and when you are young, you should have the courage to try
AOSP ~ Logcat 持久化
AUTOCAD——文字显示方式、CAD怎么直接打开天正图纸
2022 Guangxi provincial safety officer C certificate examination questions and mock examination
RSLO:自监督激光雷达里程计(实时+高精度,ICRA2022)
当技术人成长为 CEO,应该修改哪些“Bug”?