A题
Yet Another Tetris Problem
题意:
俄罗斯方块,从1到n每个位置的初始高度是ai,每行填满可以消掉,问能不能通过放2*1的方块(高2宽1,可以无限放)使全部的方块消去。
题解:
每次放2 *1的方块 每个ai的奇偶性不会改变,所以只要有偶数或者只有奇数才能全部消去,循环判断一下就可以了
AC代码
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define endl '\n'
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int mod=1e9+7;
//const int mod=998244353;
const double eps = 1e-10;
const double pi=acos(-1.0);
const int maxn=1e5+10;
const ll inf=0x3f3f3f3f;
int a[110];
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
//freopen("in.txt","r",stdin);
//freopen("out.txt","w",stdout);
int t;cin>>t;
while(t--){
int n;cin>>n;
int a=0,b=0;
for(int i=1;i<=n;i++){
int x;cin>>x;
if(x&1)a++;
else b++;
}
if(a&&b)cout<<"NO"<<endl;
else cout<<"YES"<<endl;
}
return 0;
}
B题
Yet Another Palindrome Problem
题意:
给你n个数,判断n个数里能不能取出3个组成回文数
题解:
3个数组成回文数 第一个和第三个一定相等,所以只要找到有两个数相等的,但这两个数又不能相邻,所以如果有两个相等的数相邻只能算一个数,最后判断一下只要某个数超过两个就yes
AC代码
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define endl '\n'
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int mod=1e9+7;
//const int mod=998244353;
const double eps = 1e-10;
const double pi=acos(-1.0);
const int maxn=1e5+10;
const ll inf=0x3f3f3f3f;
int a[5010],cnt[5010];
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
//freopen("in.txt","r",stdin);
//freopen("out.txt","w",stdout);
int t;cin>>t;
while(t--){
int n;cin&