eolymp
bolt
Try our new interface for solving problems
Problems

Checking for an undirected graph

published at 11/9/11, 6:35:54 pm

На главной диагонали может стоять что угодно или обязательно нули?

awpris replied:
Условие полное.
published at 2/2/15, 10:14:58 pm

простий означає без петель?

published at 1/27/24, 9:46:33 am

include <bits/stdc++.h>

using namespace std; bool t=false; int main() { int n,m,u,v ; int say=0; cin>>n; vector<vector<int>>a(n,vector<int>(n,0));

for(int i=0; i<n;i++){ for(int j=0; j<n; j++){

cin>>a[i][j];

}

} for(int i=0;i<n;i++){ for(int j=0;j<n; j++){

if(a[i][j]!=a[j][i] ||(i==j && a[i][j]==1)){ t=false; break; } else { t=true;

}

}
if(!t){
    break;
}

} if(t==true){ cout<<"YES"; } else if(t==false ){ cout<<"NO"; } }