沐枫NOI 30. African Crossword
来源:互联网 发布:小猪o2o源码下载 编辑:程序博客网 时间:2024/06/08 15:43
An African crossword is a rectangular table n×m in size. Each cell of the table contains exactly one letter. This table (it is also referred to as grid) contains some encrypted word that needs to be decoded.
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
The first line contains two integers n and m (1≤n,m≤100). Next n lines contain m lowercase Latin letters each. That is the crossword grid.
Output
Print the encrypted word on a single line. It is guaranteed that the answer consists of at least one letter.
Examples
Input
3 3cbabcdcbc
Output
abcd
Input
5 5fcofdooedoafaoardcdfeofsf
Output
codeforces
#include<iostream> #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> #include<queue> #include<stack> using namespace std; char ma[105][105]; int v[105][105]; int n,m; int check(int x,int y) { int flag=0; for(int i=0;i<n;i++) if(i!=x&&ma[x][y]==ma[i][y]) v[i][y]=1,flag=1; for(int i=0;i<m;i++) if(i!=y&&ma[x][y]==ma[x][i]) v[x][i]=1,flag=1; return flag; } int main(){scanf("%d%d",&n,&m); for(int i=0;i<n;i++) scanf("%s",ma[i]); for(int i=0;i<n;i++) { for(int j=0;j<m;j++) { int ans=check(i,j); if(ans) v[i][j]=1; } } for(int i=0;i<n;i++) { for(int j=0;j<m;j++) if(!v[i][j]) printf("%c",ma[i][j]); } return 0; }
- 沐枫NOI 30. African Crossword
- Codeforces 90B-African Crossword
- CodeForces 90B African Crossword【模拟】
- Codeforces Beta Round #74 (Div. 2) / 90B African Crossword (模拟)
- 沐枫NOI 10. Leaders
- 沐枫NOI 14. Football
- 沐枫NOI 17. Volleyball
- 沐枫NOI 28. Queue
- NOI
- 沐枫NOI 21. Restoring Password
- 沐枫NOI 25. Binary Number
- 沐枫NOI 2839. 单词替换
- Crossword Answers
- Crossword Answers
- Crossword Answers
- Crossword Answers
- Poem by an African kid
- 沐枫NOI 6. Help Chef Gerasim 模拟
- arcgis api for javascript 计算长度和面积
- lnmp一键安装包环境下让nginx支持thinkphp
- Intellij idea模拟客户端请求
- 如何将matplotlib中全局的中文设置成宋体
- 求和
- 沐枫NOI 30. African Crossword
- hiho 1623 有歧义的号码 [Offer收割]编程练习赛35 Problem A
- 上市公司财务报告的那点事(7):我的2017选股指南
- Leetcode算法学习日志-62 Unique Paths
- 例001 判断某一年是否为闰年
- 农业公司
- 我的电路实践
- java面试总结(一)- 多线程
- 002 如何修改远程仓库地址?