Codeforces Round #627(Div.3)题解

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&
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值