0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-23 20:48:48 +00:00

G - Triangle

https://atcoder.jp/contests/abc258/submissions/32935224
This commit is contained in:
Baoshuo Ren 2022-07-02 21:53:13 +08:00
parent 05a190d4b2
commit f130022441
Signed by: baoshuo
GPG Key ID: 00CB9680AB29F51A

40
AtCoder/ABC258/G/G.cpp Normal file
View File

@ -0,0 +1,40 @@
#include <iostream>
#include <bitset>
using std::cin;
using std::cout;
const char endl = '\n';
const int N = 3005;
int n;
long long ans;
std::bitset<N> 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;
}