• codeforces1210——A.Anadi and Domino(思维+枚举)


    原题链接
    思路:
    我们可以给每个点都标号,然后和每个点相连的边上放的骨牌的标号和点的标号相同。这样可以看出当n<=6时,每个边都可以放骨牌,并且不会冲突。当n==7时,就意味着有两个点的标号一样,这样就会有一些边上没有骨牌,只需要记录一下就好了。
    有·思维。
    代码:

    #pragma GCC optimize(3)
    #pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline")
    #pragma GCC optimize(2)
    #include<bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    typedef unsigned long long ull;
    typedef pair<ll,ll>PLL;
    typedef pair<int,int>PII;
    typedef pair<double,double>PDD;
    #define I_int ll
    inline ll read()
    {
        ll x=0,f=1;char ch=getchar();
        while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
        while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
        return x*f;
    }
    char F[200];
    inline void out(I_int x) {
        if (x == 0) return (void) (putchar('0'));
        I_int tmp = x > 0 ? x : -x;
        if (x < 0) putchar('-');
        int cnt = 0;
        while (tmp > 0) {
            F[cnt++] = tmp % 10 + '0';
            tmp /= 10;
        }
        while (cnt > 0) putchar(F[--cnt]);
        //cout<<" ";
    }
    ll ksm(ll a,ll b,ll p){ll res=1;while(b){if(b&1)res=res*a%p;a=a*a%p;b>>=1;}return res;}
    const ll inf = 0x3f3f3f3f3f3f3f3f;
    const int maxn=1e6+100,N=1e6+100;
    const double PI = atan(1.0)*4;
    const double eps=1e-6;
    int mp[15][15];
    int main(){
        int n=read(),m=read();
        for(int i=1;i<=m;i++){
            int u=read(),v=read();
            mp[u][v]=mp[v][u]=1;
        }
        if(n<=6) out(m);
        else{
            int cnt=inf;
            for(int i=1;i<=7;i++)
                for(int j=1;j<=7;j++){
                    ///i和j填充相同的数字
                    int tmp=0;
                    for(int k=1;k<=7;k++)
                        if(mp[i][k]&&mp[j][k]) tmp++;///不能添加的边
                    cnt=min(cnt,tmp);
                }
            out(m-cnt);
        }
        return 0;
    }
    
    

    参考

  • 相关阅读:
    MSSQL 2012 密钥
    同台同时多开DELPHI2007的解决办法
    DELPHI快捷键
    Delphi编码规范
    解决Delphi 2010启动时卡死并报“displayNotification: 堆栈溢出”错误
    Test
    sched python 定时任务
    springboot2.x 整合redis
    springboot 忽略null属性值,不传递
    logback.xml 配置使用
  • 原文地址:https://www.cnblogs.com/OvOq/p/14853082.html
Copyright © 2020-2023  润新知