#include<iostream> #include<bits/stdc++.h> using namespace std; int ar[105][105]; int main(){ int n,m; while(cin>>n>>m){ memset(ar,0,sizeof(ar)); int a,b; for(int i=0;i<m;i++){ cin>>a>>b; ar[a][b]=1; } for(int i=1;i<=n;i++){ for(int j=1;j<=n;j++){ for(int k=1;k<=n;k++){ if(ar[j][k]==1 && ar[i][j]==1){ ar[i][k]=1; } } } } bool flag=true; for(int i=1;i<=n;i++){ for(int j=1;j<=n;j++){ if(ar[i][j]==1 &&ar[j][i]==1){ flag=false; } } } if(flag==true){ cout<<"RIGHT"<<endl; } else{ cout<<"ERROR"<<endl; } } } |
Double click to view unformatted code.