# Goodbye 2019

QAQ：这场比赛在凌晨，于是乎没打。开了重现，A掉三题，这大概就是我现在的水平了吧

## A. Card Game

#include<bits/stdc++.h>
using namespace std;
int a[105],b[105];
int main()
{
int T;
cin >> T;
while(T--)
{
int n,k1,k2;
cin >> n >> k1 >> k2;
for(int i = 0;i<k1;i++)
{
cin >> a[i];
}
for(int i =0;i<k2;++i)
cin >> b[i];
bool flag = false;
for(int i = 0;i<k1;++i)
{
if(a[i]==n)
{
flag = true;
break;
}
}
if(flag)
printf("YES\n");
else
printf("NO\n");
}
return 0;
}

## B. Interesting Subarray

#include<bits/stdc++.h>
using namespace std;
const int maxn = 2e5+10;
int num[maxn];
int main()
{
int T;
cin >> T;
while(T--)
{
int n;
cin >> n;
for(int i = 0;i<n;i++)
{
cin >>num[i];
}
bool flag = false;
int l = 0,r = 0;
for(int i =0;i<n-1;i++)
{
if(abs(num[i]-num[i+1])>1)
{
flag =true;
l = i,r = i+1;
break;
}
}
if(!flag)
printf("NO\n");
else
{
printf("YES\n");
printf("%d %d\n",l+1,r+1);
}

}
return 0;
}

## C. Make Good

#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn = 1e5+10;
LL num[maxn];
int main()
{
int T;
cin >>T;
while(T--)
{
int n;
cin >> n;
for(int i = 0;i<n;++i)
{
cin >> num[i];
}
LL ans = num[0],ans2 = num[0];
for(int i = 1;i<n;i++)
{
ans+=num[i];
ans2^=num[i];
}
if(ans == ans2*2)
{
printf("0\n\n");
}
else
{
cout << 2 << endl;
cout << ans2 << " " << ans+ans2 << endl;
}
}
return 0;
}

Ps:  以下题解均来自cf的官方题解

## D. Strange Device

#include <bits/stdc++.h>

using namespace std;

int main() {
ios_base::sync_with_stdio(0);
cin.tie(nullptr);

int n, k;
cin>>n>>k;
vector<int> elements;
for (int i = 1; i<=k+1; i++)
{
cout<<"? ";

for (int j = 1; j<=k+1; j++) if (j!=i) cout<<j<<' ';
cout<<endl;

int pos, el;
cin>>pos>>el;
elements.push_back(el);
}
int maxx = elements[0];
for (auto it: elements) maxx = max(maxx, it);
int m = 0;
for (auto it: elements) if (it==maxx) m++;
cout<<"! "<<m<<endl;

}

## E. Divide Points

#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e3+10;
struct Node
{
int x,y;
Node(int _x = 0,int _y = 0):x(_x),y(_y) {}
};
Node Point[maxn];
int cnt[3][3]  = {0};
int main()
{
int n;
scanf("%d",&n);
for(int i = 0; i<n; i++)
{
scanf("%d %d",&Point[i].x,&Point[i].y);
Point[i].x+=int(1e6);
Point[i].y+=int(1e6);
}
while(true)
{
memset(cnt,0,sizeof(cnt));
for(int i = 0; i<n; ++i)
{
int x = Point[i].x,y = Point[i].y;
++cnt[x%2][y%2];
}
if(cnt[0][0]+cnt[1][1]>0&&cnt[0][1]+cnt[1][0]>0)
{
printf("%d\n",cnt[0][0]+cnt[1][1]);
int cur = 0;
for(int i = 0; i<n; i++)
{
int x = Point[i].x,y = Point[i].y;
if((x%2==0&&y%2==0)||(x%2==1&&y%2==1))
{
if(cur==0)
printf("%d",i+1);
else
printf(" %d",i+1);
++cur;
}
}
return 0;
}
if(cnt[0][0]+cnt[1][0]>0&&cnt[1][1]+cnt[0][1]>0)
{
printf("%d\n",cnt[0][0]+cnt[1][0]);
int cur = 0;
for(int i = 0; i<n; i++)
{
int x = Point[i].x,y = Point[i].y;
if((x%2==0&&y%2==0)||(x%2==1&&y%2==0))
{
if(cur==0)
printf("%d",i+1);
else
printf(" %d",i+1);
++cur;
}
}
return 0;
}
int x = 0;
int y = 0;
for(int i = 0; i<2; ++i)
{
for(int j = 0; j<2; ++j)
{
if(cnt[i][j])
{
x = i;
y = j;
break;
}
}
}
for(int i = 0; i<n; i++)
{
Point[i].x = (Point[i].x-x)/2;
Point[i].y = (Point[i].y-y)/2;
}
// return p;
}

return 0;
}

## G.Subset with Zero Sum

#include <bits/stdc++.h>
using namespace std;
void solve()
{
int n;
cin >> n;
vector<int> a(n+1);
for(int i = 1;i<=n;++i)
cin >> a[i];
vector<bool> visited(n+1);
int cur = 1;
while(!visited[cur])
{
visited[cur] = true;
cur = cur -a[cur];
}
vector<int> ans = {cur};
int cur1 = cur - a[cur];
while(cur1!=cur)
{
ans.push_back(cur1);
cur1 = cur1-a[cur1];
}
cout << ans.size() << '\n';
for(auto it:ans) cout << it << " ";
cout << '\n';
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(nullptr);
int t;
cin >> t;
for(int i = 0;i<t;i++)
solve();
return 0;
}
posted @ 2020-01-08 16:57  浅花迷人  阅读(...)  评论(...编辑  收藏