結果

問題 No.488 四角関係
ユーザー 小指が強い人
提出日時 2016-02-13 14:15:01
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 4 ms / 5,000 ms
コード長 732 bytes
コンパイル時間 781 ms
コンパイル使用メモリ 75,328 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-09-22 06:14:53
合計ジャッジ時間 1,547 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <fstream>
#include <random>
#include <string>
using namespace std;
#define REP(i, x, n) for(int i = x; i < n; i++)
bool a[100][100] = {0};

bool isSquare(int i, int j, int k, int l) {
    return a[i][j] && a[j][k] && a[k][l] && a[l][i] && !a[i][k] && !a[j][l];
}

int main(int argc, char* argv[])
{
    int n, m;
    cin >> n >> m;
    REP(i,0,m) {
        int p, q;
        cin >> p >> q;
        a[p][q] = a[q][p] = true;
    }
    int res = 0;
    REP(i,0,n)
     REP(j,i+1,n)
      REP(k,j+1,n)
       REP(l,k+1,n) {
         if(isSquare(i, j, k, l)) res++;
         else if(isSquare(i, k, j, l)) res++;
         else if(isSquare(i, j, l, k)) res++;
       }
    cout << res << endl;
    return 0;
}
0