Cod sursa(job #19529)

Utilizator damaDamaschin Mihai dama Data 19 februarie 2007 18:29:57
Problema Amlei Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 1.48 kb
#include <stdio.h>
#include <vector>
#include <algorithm>

using namespace std;

vector< vector<int> > v(501, vector<int>(51, 0)) , w(501, vector<int> (51, 0));
int n, t, u;

bool cmp(vector<int> one, vector<int> two)
{
	int i = 0;
	while(one[i] == two[i] && i < one.size())
	{
		++i;
	}
	if(one[i] < two[i])
		return 1;
	return 0;
}

int main()
{
	freopen("amlei.in","r",stdin);
	freopen("amlei.out","w",stdout);
	
	int i, j, a, ok;
	
	while(!feof(stdin))
	{
		scanf("%d%d%d ", &n, &t, &u);
		for(i = 0; i < t; ++i)
		{
			for(j = 0; j < n; ++j)
			{
				scanf("%d", &a);
				v[i][j] = a;;		
			}
			sort(v[i].begin(), v[i].begin() + n);
		}
		scanf("/n");
		sort(v.begin(), v.begin() + t);
		/*
		for(i = 0; i < t; ++i)
		{
			for(j = 0; j < n; ++j)
			{
				printf("%d ", v[i][j]);
			}
		}
		printf("\n");
		*/
		for(i = 0; i < u; ++i)
		{
			for(j = 0; j < n; ++j)
			{
				scanf("%d", &a);
				w[i][j] = a;
			}
			sort(w[i].begin(), w[i].begin() + n);
		}
		sort(w.begin(), w.begin() + u);
		/*
		for(i = 0; i < u; ++i)
		{
			for(j = 0; j < n; ++j)
			{
				printf("%d ", w[i][j]);
			}
		}
		printf("\n");
		*/
		i = j = 0;
		ok = 1;
		while(i < t && j < u)
		{
			while(v[i] == v[i + 1] && i < t - 1)
				++i;
			while(w[j] == w[j + 1] && j < u - 1)
				++j;
			if(v[i] != w[j])
			{
				printf("NU\n");
				ok = 0;
				break;
			}
			++i;
			++j;
		}
		if(ok)
			printf("DA\n");
		scanf(" ");
	}
	
	return 0;
}