結果
問題 | No.488 四角関係 |
ユーザー |
![]() |
提出日時 | 2017-02-25 10:31:56 |
言語 | C90 (gcc 12.3.0) |
結果 |
AC
|
実行時間 | 78 ms / 5,000 ms |
コード長 | 1,419 bytes |
コンパイル時間 | 206 ms |
コンパイル使用メモリ | 24,448 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-11 14:54:12 |
合計ジャッジ時間 | 1,567 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 22 |
コンパイルメッセージ
main.c: In function ‘main’: main.c:33:5: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 33 | scanf("%d %d", &n, &m); | ^~~~~~~~~~~~~~~~~~~~~~ main.c:38:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 38 | scanf("%d %d", &a, &b); | ^~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include <stdio.h> #include <stdlib.h> #include <stdbool.h> #include <string.h> #include <math.h> #define rep(i, n) for (i = 0; i < n; i++) #define rrep(i, n) for (i = n; i >= 0; i--) #define max(a, b) (a > b ? a : b) #define min(a, b) (a < b ? a : b) typedef long long ll; bool graph[50][50]; int cntEdge(int a, int b, int c, int d, int x) { int i, cnt = 0; if (a != x && graph[a][x]) cnt++; if (b != x && graph[b][x]) cnt++; if (c != x && graph[c][x]) cnt++; if (d != x && graph[d][x]) cnt++; return cnt; } bool isSquare(int a, int b, int c, int d) { int ae = cntEdge(a, b, c, d, a); int be = cntEdge(a, b, c, d, b); int ce = cntEdge(a, b, c, d, c); int de = cntEdge(a, b, c, d, d); return ae == 2 && be == 2 && ce == 2 && de == 2; } int main() { int n, m; scanf("%d %d", &n, &m); int i, j, k, l; rep(i, m) { int a, b; scanf("%d %d", &a, &b); graph[a][b] = true; graph[b][a] = true; } int ans = 0; rep(i, n) rep(j, n) { while (i == j) j++; if (j >= n) break; rep(k, n) { while (i == k || j == k) k++; if (k >= n) break; rep(l, n) { while (i == l || j == l || k == l) l++; if (l >= n) break; if (isSquare(i, j, k, l)) ans++; } } } printf("%d\n", ans / 24); return 0; }