結果

問題 No.488 四角関係
ユーザー startcpp
提出日時 2017-02-24 22:56:40
言語 C++11
(gcc 13.3.0)
結果
AC  
実行時間 6 ms / 5,000 ms
コード長 958 bytes
コンパイル時間 594 ms
コンパイル使用メモリ 59,556 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2025-01-02 23:33:52
合計ジャッジ時間 1,429 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

#include <iostream>
#define rep(i, l, r) for(i = l; i < r; i++)
using namespace std;
int n;
bool is_connect[50][50] = {false};
bool check(int a, int b, int c, int d) {
int i, j;
int id[4] = {a, b, c, d};
bool used[4] = {false};
int now = 0;
used[0] = true;
rep(i, 0, 3) {
rep(j, 0, 4) {
if (used[j] || !is_connect[id[now]][id[j]]) continue;
used[j] = true;
now = j;
break;
}
if (j == 4) return false;
}
if (!is_connect[id[now]][id[0]]) return false;
rep(i, 0, 4) {
int cnt = 0;
rep(j, 0, 4) {
if (i == j) continue;
if (is_connect[id[i]][id[j]]) cnt++;
}
if (cnt != 2) return false;
}
return true;
}
int main() {
int m, a, b;
int i, j, k, l;
cin >> n >> m;
rep(i, 0, m) {
cin >> a >> b;
is_connect[a][b] = true;
is_connect[b][a] = true;
}
int ans = 0;
rep(i, 0, n)
rep(j, i + 1, n)
rep(k, j + 1, n)
rep(l, k + 1, n)
ans += check(i, j, k, l);
cout << ans << endl;
return 0;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0