0
点赞
收藏
分享

微信扫一扫

Codeforces Beta Round #74 (Div. 2) / 90B African Crossword (模拟)


B. African Crossword



http://codeforces.com/problemset/problem/90%2FB



time limit per test



memory limit per test



input



output


n × m

To solve the crossword you should cross out all repeated letters in rows and columns. In other words, a letter should only be crossed out if and only if the corresponding column or row contains at least one more letter that is exactly the same. Besides, all such letters are crossed out simultaneously.

When all repeated letters have been crossed out, we should write the remaining letters in a string. The letters that occupy a higher position follow before the letters that occupy a lower position. If the letters are located in one row, then the letter to the left goes first. The resulting word is the answer to the problem.

You are suggested to solve an African crossword and print the word encrypted there.


Input



n and m (1 ≤ n, m ≤ 100). Next n lines contain m


Output



Print the encrypted word on a single line. It is guaranteed that the answer consists of at least one letter.


Sample test(s)



input



3 3 cba bcd cbc



output



abcd



input



5 5 fcofd ooedo afaoa rdcdf eofsf



output



codeforces


学英语:

When all repeated letters have been crossed out, we should write the remaining letters in a string.

当所有重复的字母都被划掉时,我们就把剩下的字母写到一个字符串里。


完整代码:

/*30ms,0KB*/

#include<cstdio>

int main()
{
	int n, m;
	scanf("%d%d", &n, &m);
	char arr[110][110];
	int i, j, k, f;
	for (i = 0; i < n; i++)
		scanf("%s", arr[i]);
	for (i = 0; i < n; i++)
	{
		for (j = 0; j < m; j++)
		{
			f = 0;
			for (k = 0; k < m; k++)
			{
				if (arr[i][j] == arr[i][k] && j != k)
				{
					f = 1;
					break;
				}
			}
			if (f != 1)
			{
				for (k = 0; k < n; k++)
				{
					if (arr[i][j] == arr[k][j] && i != k)
					{
						f = 1;
						break;
					}
				}
			}
			if (f != 1)
				putchar(arr[i][j]);
		}
	}
	putchar('\n');
	return 0;
}




举报

相关推荐

0 条评论