Codeforces Round #438 C 868C Qualification Rounds(思维,非状压dp)

注意到这题很多大佬都是用的类似状压dp的方法,但是我不会啊..
虽然想了很久很久..
菜如狗的我
具体看代码,虽然丑,但是清晰.
事实上,只要分四种情况特判即可.
只有第四种有一些难度.
(似乎我这个思路挺奇怪的??)

/*  xzppp  */
#include <iostream>
#include <vector>
#include <cstdio>
#include <string.h>
#include <algorithm>
#include <queue>
#include <set>
#include <string>
#include <cmath>
#include <bitset>
#include <iomanip>
using namespace std;
#define FFF freopen("in.txt","r",stdin);freopen("out.txt","w",stdout);
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define MP make_pair
#define PB push_back
#define _ %MOD
typedef long long  LL;
typedef unsigned long long ULL;
typedef pair<int,int > pii;
typedef pair<LL,LL> pll;
typedef pair<double,double > pdd;
typedef pair<double,int > pdi;
const int MAXM = 2e3+17;
const int MAXV = 2*1e3+17;
const int BIT = 15+3;
const int INF = 0x7fffffff;
const LL INFF = 0x3f3f3f3f3f3f3f3f;
const int MOD = 1e9+7;
#include <map>
const int MAXN = 1e5+17;
struct dap
{
    int s;
    string str;
}all[MAXN];
set<int > st[4+3];
map<string,int > mp;
int main()
{    
        #ifdef GoodbyeMonkeyKing
    FFF
    #endif
    int n,k;
    cin>>n>>k;
    int mx = 0;
    int tm[4+3]= {0};
    for (int i = 0; i < n; ++i)
    {
        int sm = 0;
        all[i].str.clear();
        for (int j = 0; j < 4; ++j)
        {

            int temp;
            if(j<k)         
                scanf("%d",&temp);
            else
                temp = 0;
            all[i].str.push_back(temp+'0');
            if(temp==0)
            {
                st[j].insert(i);
                all[i].s++;
                sm++;
            }
        }
        if(k==4)
        {
            mp[all[i].str] = 1;
            //cout<<all[i].str<<endl;
        }
        if(sm>=mx)
        {
            mx = sm;
        }
    }
    //cout<<mx<<endl;
    if(k==1)
    {
        if(!st[0].empty())
            cout<<"YES"<<endl;
        else
            cout<<"NO"<<endl;
    }
    else if(k==2)
    {
        if(!st[0].empty()&&!st[1].empty())
            cout<<"YES"<<endl;
        else
            cout<<"NO"<<endl;
    }
    else if(k==3)
    {
        mx--;
        if(mx<2)
            cout<<"NO"<<endl;
        else if(mx==3)
            cout<<"YES"<<endl;
        else
        {
            if(!st[0].empty()&&!st[1].empty()&&!st[2].empty())
                cout<<"YES"<<endl;
            else
                cout<<"NO"<<endl;
        }
    }
    else
    {
        if(mx<2)
            cout<<"NO"<<endl;
        else if(mx==4)
            cout<<"YES"<<endl;
        else if(mx==3)
        {
            if(!st[0].empty()&&!st[1].empty()&&!st[2].empty()&&!st[3].empty())
                cout<<"YES"<<endl;
            else
                cout<<"NO"<<endl;
        }
        else
        {
            if(mp["1001"]==1&&mp["0110"]==1)
                cout<<"YES"<<endl;
            else if(mp["1100"]==1&&mp["0011"]==1)
                cout<<"YES"<<endl;
            else if(mp["1010"]==1&&mp["0101"]==1)
                cout<<"YES"<<endl;
            else
                cout<<"NO"<<endl;
        }

    }
    return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值