From f130022441adb67c1e9c3bd61597918256598b17 Mon Sep 17 00:00:00 2001 From: Baoshuo Date: Sat, 2 Jul 2022 21:53:13 +0800 Subject: [PATCH] G - Triangle https://atcoder.jp/contests/abc258/submissions/32935224 --- AtCoder/ABC258/G/G.cpp | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 AtCoder/ABC258/G/G.cpp diff --git a/AtCoder/ABC258/G/G.cpp b/AtCoder/ABC258/G/G.cpp new file mode 100644 index 00000000..c3fed774 --- /dev/null +++ b/AtCoder/ABC258/G/G.cpp @@ -0,0 +1,40 @@ +#include +#include + +using std::cin; +using std::cout; +const char endl = '\n'; + +const int N = 3005; + +int n; +long long ans; +std::bitset g[N]; + +int main() { + std::ios::sync_with_stdio(false); + cin.tie(nullptr); + + cin >> n; + + for (int i = 1; i <= n; i++) { + for (int j = 1; j <= n; j++) { + char c; + cin >> c; + + if (c == '1') g[i][j] = g[j][i] = 1; + } + } + + for (int i = 1; i <= n; i++) { + for (int j = i + 1; j <= n; j++) { + if (g[i][j]) { + ans += (g[i] & g[j]).count(); + } + } + } + + cout << ans / 3 << endl; + + return 0; +}