View Code of Problem 131

#include<iostream>
#include<cstdio>

using namespace std;
int sign[100]={0};
struct crouse
{
	int pre;
	int seq;
}c[1002];

int main()
{
	int n, m, count;
	while(cin >> n >> m)
	{
		int flag = 0;
		for(int i = 0; i < m; i++)
		{
			cin >> c[i].pre >> c[i].seq;
			if(sign[c[i].pre] == 0)
			{
				sign[c[i].pre] = 1;
				count++;
			}
			if(sign[c[i].seq] == 0)
			{
				sign[c[i].seq] = 1;
				count++;
			}
		}
		for(int i = 0; i < m; i++)
		{
			int start = c[i].pre;
			int next = c[i].seq;
			for(int j = 0; j < m; j++)
				if(i != j)
				{
					if(next == c[j].pre)
					{
						next = c[j].seq;
						j = 0;
					}
					if(next == start)
					{
						flag = 1;
						break;
					}
				}
			if(flag)
			{
				cout << "ERROR" << endl;
				break;
			}
		}
		if(!flag)
			cout << "RIGHT" << endl;
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 131