From f2694dcba34af40cd7361981b9c549df87ce8d84 Mon Sep 17 00:00:00 2001 From: Baoshuo Date: Wed, 12 Oct 2022 07:59:03 +0800 Subject: [PATCH] E - Strictly Positive Matrix https://codeforces.com/contest/402/submission/175552659 --- Codeforces/402/E/E.cpp | 44 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 Codeforces/402/E/E.cpp diff --git a/Codeforces/402/E/E.cpp b/Codeforces/402/E/E.cpp new file mode 100644 index 00000000..6d92d67b --- /dev/null +++ b/Codeforces/402/E/E.cpp @@ -0,0 +1,44 @@ +#include +#include + +using std::cin; +using std::cout; +const char endl = '\n'; + +const int N = 2005; + +int n; +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, x; j <= n; j++) { + cin >> x; + + g[i][j] = x; + } + } + + for (int i = 1; i <= n; i++) { + for (int j = 1; j <= n; j++) { + if (g[j][i]) g[j] |= g[i]; + } + } + + for (int i = 1; i <= n; i++) { + if (g[i].count() != n) { + cout << "NO" << endl; + + exit(0); + } + } + + cout << "YES" << endl; + + return 0; +}