結果

問題 No.488 四角関係
ユーザー kurenai3110kurenai3110
提出日時 2017-02-24 22:54:27
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 787 bytes
コンパイル時間 577 ms
コンパイル使用メモリ 67,708 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-30 23:37:50
合計ジャッジ時間 1,603 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 1 ms
4,384 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 1 ms
4,380 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 1 ms
4,380 KB
testcase_22 WA -
testcase_23 AC 2 ms
4,380 KB
testcase_24 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
using namespace std;

#define YEAR 2017
bool E[50][50];


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


	for (int i = 0; i < m; i++) {
		int a, b; cin >> a >> b;
		E[a][b] = true;
		E[b][a] = true;
	}

	int ans = 0;
	for (int i = 0; i < n; i++) {
		queue<int>que; que.push(i);
		vector<int>a(n,10000);
		a[i] = 0;
		while (!que.empty()) {
			int p = que.front();que.pop();
			for (int j = 0; j < n; j++) {
				if (i == j)continue;
				if (E[p][j]) {
					if (a[j] == 2 && a[p] == 1)ans++;
					if (a[j] == 10000)a[j] = a[p] + 1;
					if (a[p] == 0)que.push(j);
				}
			}
			for (int j = 0; j < n; j++) {
				E[p][j] = false;
				E[j][p] = false;
			}
		}
	}
	cout << ans << endl;
    return 0;
}

0