結果

問題 No.488 四角関係
ユーザー anta
提出日時 2017-02-24 22:26:25
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 84 ms / 5,000 ms
コード長 1,125 bytes
コンパイル時間 1,876 ms
コンパイル使用メモリ 163,240 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2025-01-02 22:44:11
合計ジャッジ時間 3,487 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:17:30: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   17 |                         scanf("%d%d", &A, &B);
      |                         ~~~~~^~~~~~~~~~~~~~~~

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
template<typename T, typename U> static void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> static void amax(T &x, U y) { if (x < y) x = y; }

int main() {
	int N; int M;
	while (~scanf("%d%d", &N, &M)) {
		bool g[50][50] = {};
		rep(i, M) {
			int A; int B;
			scanf("%d%d", &A, &B);
			g[A][B] = g[B][A] = true;
		}
		int ans = 0;
		rep(i, N) rep(j, i) rep(k, j) rep(l, k) {
			int perm[4] = { i,j,k,l };
			sort(perm, perm + 4);
			do {
				bool ok = true;
				rep(p, 4) {
					ok &= g[perm[p]][perm[(p + 1) % 4]];
					ok &= !g[perm[p]][perm[(p + 2) % 4]];
				}
				ans += ok;
			} while (next_permutation(perm, perm + 4));
		}
		ans /= 8;
		printf("%d\n", ans);
	}
	return 0;
}
0