当前位置:网站首页>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();
}
}
边栏推荐
- 请问股票开户收费吗 网上开户安全吗?
- Easy express: we use Zadig to realize 10000 times of construction and deployment, smart operation and maintenance, and release development productivity
- Jerry's configuration of TWS cross pairing [chapter]
- [pbootcms template] composition website / document download website source code
- Oracle expands distributed cloud services to bring comprehensive public cloud services to more customers
- MATLAB Gui 实现点击按钮,打开文件对话框,导入图片功能
- 智能垃圾桶(四)——树莓派pico实现超声波测距(HC-SR04)
- &3 在浏览器中查看请求报文和响应报文
- 跟着官方学电机,BLDC两种控制策略,学到即赚到
- 正大期货留4数据整合
猜你喜欢

Imile uses Zadig's multi cloud environment to deploy thousands of times a week to continuously deliver global business across clouds and regions

Dragon Book tiger Book whale Book gnawing? Try the monkey book with Douban score of 9.5

Embedded database development programming (IV) -- DDL, DML

亲测!Centos7部署PHP + Swoole
![Jerry's about TWS pairing mode configuration [chapter]](/img/c8/d78e817295169753244299545d9aba.png)
Jerry's about TWS pairing mode configuration [chapter]

MATLAB Gui 实现点击按钮,打开文件对话框,导入图片功能

Wonderful! Miaoying technology fully implements Zadig to help container construction, and fully embraces kubernetes and Yunyuan

Jericho's position on initiating the connection back to the opposite ear: 【 chapter 】

嵌入式数据库开发编程(四)——DDL、DML

ONES 创始人王颖奇对话《财富》(中文版):中国有没有优秀的软件?
随机推荐
[graduation season] summarize the past and look forward to the future
Deep understanding of volatile keyword
力扣每日一题-第31天-13.三角形的最大周长
地平线开发板配置网段
Dragon Book tiger Book whale Book gnawing? Try the monkey book with Douban score of 9.5
Oracle expands distributed cloud services to bring comprehensive public cloud services to more customers
杰理之手动配对方式【篇】
What is the main account of Chia Tai futures used for 4 quotation software?
bison使用error死循环的记录
Is it safe for Hengtai securities to open an account? Ranking of securities
Titanium dynamic technology: our Zadig landing Road
MMdet中的Resnet源码解读+Ghost模块
谷粒商城项目
恒泰证券开户安全吗 证券排名
Wang Yingqi, founder of ones, talks to fortune (Chinese version): is there any excellent software in China?
小白学习MySQL - 增量统计SQL的需求 - 开窗函数的方案
智能垃圾桶(四)——树莓派pico实现超声波测距(HC-SR04)
申请uniapp离线打包时的AppKey
When a technician becomes a CEO, what "bugs" should be modified?
GBase8s数据库INTO TEMP 子句创建临时表来保存查询结果。