#include #include using namespace std; int main() { int n; cin >> n; vector> graph(n, vector(n)); for (auto& line : graph) { for (auto& element : line) { cin >> element; } } bool f = false; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (i == j && graph[i][j] == 1) { f = true; } if (graph[i][j] != graph[j][i]) { f = true; } } } if (f) { cout << "NO"; } else { cout << "YES"; } return 0; }