#include<iostream> #include<cmath> #include<iomanip> #include<cstring> using namespace std; int map[101][101]; int main() { int n, m; while (cin >> n >> m) { memset(map, 0, sizeof(map)); while (m--) { int a, b; cin >> a >> b; map[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 (map[j][i] && map[i][k]) { map[j][k] = 1; } } } } int flag = 0; for (int i = 1;i <= n;i++) { for (int j = 1;j <= n;j++) { if (i != j) { if (map[i][j] && map[j][i]) { flag = 1; break; } } } } if (flag == 1) cout << "ERROR" << endl; else cout << "RIGHT" << endl; } } |
Double click to view unformatted code.