当前位置:网站首页>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();
}
}
边栏推荐
- GBase8s数据库FOR UPDATE 子句
- ERP编制物料清单 基础
- [pbootcms模板]作文网站/文档下载网站源码
- When a technician becomes a CEO, what "bugs" should be modified?
- 杰理之WiFi干扰蓝牙【篇】
- &4 express框架
- 杰理之发起对耳配对、回连、开启可发现、可连接的轮循函数【篇】
- Jerry's about TWS pairing mode configuration [chapter]
- Some printer driver PPD files of Lenovo Lingxiang lenovoimage
- GBase8s数据库与 FOR UPDATE 子句不兼容的语法
猜你喜欢

杰理之关于 TWS 交叉配对的配置【篇】

Easy express: we use Zadig to realize 10000 times of construction and deployment, smart operation and maintenance, and release development productivity

跟着官方学电机,BLDC两种控制策略,学到即赚到

亲测!Centos7部署PHP + Swoole

Ttchat x Zadig open source co creates helm access scenarios, and environmental governance can be done!

ERP编制物料清单 基础

Pytoch - distributed communication primitive (with source code)

普通用户使用vscode登录ssh编辑root文件

LM07丨细聊期货横截面策略

启泰观察:职业精英创业必踩巨坑之 --- 学习效果坑
随机推荐
Jerry's initiation of ear pairing, reconnection, and opening of discoverable and connectable cycle functions [chapter]
检查YAML文件安全配置:kubesec
[pbootcms模板]作文网站/文档下载网站源码
pod安全策略(PSP)
Is the table queried by this EMR sparksql node ODPs?
普通用户使用vscode登录ssh编辑root文件
[pbootcms template] composition website / document download website source code
Windwos10安装sshd服务
小白学习MySQL - 增量统计SQL的需求 - 开窗函数的方案
shell判断命令是否执行成功
易快报:我们用 Zadig 实现万次构建部署,聪明运维,释放开发生产力
助力极致体验,火山引擎边缘计算最佳实践
杰理之关于开机发起回连对耳的位置:【篇】
MMdet中的Resnet源码解读+Ghost模块
Information technology application and innovation professionals (database) intermediate training hot enrollment (July 6-10)
SOFARegistry 源码|数据同步模块解析
How to view saved passwords of websites
Equals increases execution speed / performance optimization
跟着官方学电机,BLDC两种控制策略,学到即赚到
杰理之关于 TWS 交叉配对的配置【篇】