結果

問題 No.488 四角関係
ユーザー bttb0209bttb0209
提出日時 2017-03-02 23:17:19
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 109 ms / 5,000 ms
コード長 1,472 bytes
コンパイル時間 732 ms
コンパイル使用メモリ 79,876 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-03 21:14:44
合計ジャッジ時間 2,207 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <stdlib.h>
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>

#define MAX(a,b) ((a)>(b) ? (a) : (b))
#define MIN(a,b) ((a)<(b) ? (a) : (b))
#define ABS(a) ((a)>0 ? (a) : (a * -1))

using namespace std;


struct Node{
	vector<int>p;
};

int main(){
	int n, m, x, y, buf1, buf2, buf3, buf4, ans;
	cin >> n >> m;
	vector<Node> nd(n);
	ans = 0;

	for (int i = 0; i < m; i++) {
		cin >> x >> y;
		nd[x].p.push_back(y);
		nd[y].p.push_back(x);
	}

	for (int h = 0; h < n; h++) {
		for (int j = h + 1; j < n; j++) {
			for (int k = j + 1; k < n; k++) {
				for (int l = k + 1; l < n; l++) {
					buf1 = buf2 = buf3 = buf4 = 0;
					buf1 += count(nd[h].p.begin(), nd[h].p.end(), j);
					buf1 += count(nd[h].p.begin(), nd[h].p.end(), k);
					buf1 += count(nd[h].p.begin(), nd[h].p.end(), l);
					buf2 += count(nd[j].p.begin(), nd[j].p.end(), h);
					buf2 += count(nd[j].p.begin(), nd[j].p.end(), k);
					buf2 += count(nd[j].p.begin(), nd[j].p.end(), l);
					buf3 += count(nd[k].p.begin(), nd[k].p.end(), h);
					buf3 += count(nd[k].p.begin(), nd[k].p.end(), j);
					buf3 += count(nd[k].p.begin(), nd[k].p.end(), l);
					buf4 += count(nd[l].p.begin(), nd[l].p.end(), h);
					buf4 += count(nd[l].p.begin(), nd[l].p.end(), j);
					buf4 += count(nd[l].p.begin(), nd[l].p.end(), k);
					if (buf1 == 2 && buf2 == 2 && buf3 == 2 && buf3 == 2 && buf4 == 2) {
						ans ++;
					}
				}
			}
		}
	}

	cout << ans << endl;
}
0