結果
問題 | No.488 四角関係 |
ユーザー | togatoga |
提出日時 | 2017-02-24 23:08:14 |
言語 | C++11 (gcc 11.4.0) |
結果 |
AC
|
実行時間 | 3 ms / 5,000 ms |
コード長 | 1,888 bytes |
コンパイル時間 | 736 ms |
コンパイル使用メモリ | 99,604 KB |
実行使用メモリ | 4,380 KB |
最終ジャッジ日時 | 2023-08-30 23:43:15 |
合計ジャッジ時間 | 1,778 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge11 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,376 KB |
testcase_01 | AC | 3 ms
4,376 KB |
testcase_02 | AC | 2 ms
4,376 KB |
testcase_03 | AC | 2 ms
4,380 KB |
testcase_04 | AC | 2 ms
4,380 KB |
testcase_05 | AC | 3 ms
4,380 KB |
testcase_06 | AC | 2 ms
4,380 KB |
testcase_07 | AC | 3 ms
4,380 KB |
testcase_08 | AC | 2 ms
4,380 KB |
testcase_09 | AC | 2 ms
4,380 KB |
testcase_10 | AC | 2 ms
4,376 KB |
testcase_11 | AC | 1 ms
4,376 KB |
testcase_12 | AC | 1 ms
4,376 KB |
testcase_13 | AC | 1 ms
4,380 KB |
testcase_14 | AC | 1 ms
4,380 KB |
testcase_15 | AC | 1 ms
4,376 KB |
testcase_16 | AC | 1 ms
4,380 KB |
testcase_17 | AC | 2 ms
4,376 KB |
testcase_18 | AC | 2 ms
4,380 KB |
testcase_19 | AC | 2 ms
4,376 KB |
testcase_20 | AC | 1 ms
4,376 KB |
testcase_21 | AC | 1 ms
4,376 KB |
testcase_22 | AC | 1 ms
4,380 KB |
testcase_23 | AC | 1 ms
4,380 KB |
testcase_24 | AC | 1 ms
4,380 KB |
ソースコード
#include <algorithm> #include <bitset> #include <cassert> #include <cfloat> #include <climits> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <memory> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <utility> #include <vector> // c++11 #include <array> #include <tuple> #include <unordered_map> #include <unordered_set> #define mp make_pair #define mt make_tuple #define rep(i, n) for (int i = 0; i < (n); i++) using namespace std; using ll = long long; using ull = unsigned long long; using pii = pair<int, int>; const int INF = 1 << 29; const double EPS = 1e-9; const ll MOD = 1000000007; const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1}; const int MAX_N = 51; int N,M; int edges[MAX_N][MAX_N]; int cost[MAX_N][MAX_N]; int main() { cin >> N >> M; for (int i = 0; i < N; i++){ for (int j = 0; j < N; j++){ if (i == j)continue; edges[i][j] = INF; } } for (int i = 0; i < M; i++){ int a,b; cin >> a >> b; edges[a][b] = 1; edges[b][a] = 1; } for (int k = 0; k < N; k++){ for (int i = 0; i < N; i++){ for (int j = 0; j < N; j++){ edges[i][j] = min(edges[i][j], edges[i][k] + edges[k][j]); } } } int ans = 0; for (int i = 0; i < N; i++){ for (int j = i + 1; j < N; j++){ if (edges[i][j] == 2){ for (int k = 0; k < N; k++){ for (int l = k + 1; l < N; l++){ if (edges[i][k] == 1 and edges[j][k] == 1 and edges[i][l] == 1 and edges[j][l] == 1){ if (edges[k][l] == 2){ ans++; } } } } } } } cout << ans / 2<< endl; return 0; }