View Code of Problem 131

#include<iostream>
#include<cmath>
#include<iomanip>
#include<cstring>
using namespace std;
int num[101];
int main()
{
	memset(num, 0, sizeof(num));
	int n, m;
	while (cin >> n >> m)
	{
		int k = 0;
		int j = 100;	
		int flag = 0;
		while (m--)
		{
			int a, b;
			cin >> a >> b;
			if (num[a] >= num[b])
			{
				num[a] = j--;
				num[b] = j--;
			}
			else
			{
				flag = 1;
				break;
			}
		}
		if (flag == 0)
			cout << "RIGHT" << endl;
		else
			cout << "ERROR" << endl;
		
	}
	
	
}

Double click to view unformatted code.


Back to problem 131