結果

問題 No.488 四角関係
ユーザー imulan
提出日時 2017-02-26 03:04:10
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 54 ms / 5,000 ms
コード長 1,123 bytes
コンパイル時間 1,537 ms
コンパイル使用メモリ 167,704 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-06-11 15:35:32
合計ジャッジ時間 2,608 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

int main()
{
    int n,m;
    cin >>n >>m;

    int G[50][50]={};
    rep(i,m)
    {
        int a,b;
        cin >>a >>b;
        G[a][b]=G[b][a]=1;
    }

    int ans=0;
    int x[4];
    rep(i,n)rep(j,i)rep(k,j)rep(l,k)
    {
        x[0]=l;
        x[1]=k;
        x[2]=j;
        x[3]=i;

        do{
            int ok=1;
            rep(p,4)rep(q,4)
            {
                if((p-q+4)%4==1 || (p-q+4)%4==3)
                {
                    if(!G[x[p]][x[q]]) ok=0;
                }
                else
                {
                    if(G[x[p]][x[q]]) ok=0;
                }

                if(!ok) p=q=4;
            }
            if(ok)
            {
                ++ans;
                break;
            }
        }while(next_permutation(x,x+4));
    }
    cout << ans << endl;
    return 0;
}
0