結果

問題 No.488 四角関係
ユーザー ldsyb
提出日時 2017-02-24 23:39:44
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 3 ms / 5,000 ms
コード長 596 bytes
コンパイル時間 713 ms
コンパイル使用メモリ 65,152 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2025-01-03 00:40:12
合計ジャッジ時間 1,729 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
using namespace std;

int main(){
	int n, m, ans = 0;
	cin >> n >> m;
	bool edge[n][n]{};
	while(m--){
		int a, b;
		cin >> a >> b;
		edge[a][b] = edge[b][a] = true;
	}
	for(int i = 0; i < n; i++) for(int j = i + 1; j < n; j++) for(int k = j + 1; k < n; k++) for(int l = k + 1; l < n; l++){
		if(edge[i][j] + edge[i][k] + edge[i][l] != 2) continue;
		if(edge[j][i] + edge[j][k] + edge[j][l] != 2) continue;
		if(edge[k][i] + edge[k][j] + edge[k][l] != 2) continue;
		if(edge[l][i] + edge[l][j] + edge[l][k] != 2) continue;
		ans++;
	}
	cout << ans << endl;
}
0