African Crossword

Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u

Submit  Status  Practice  CodeForces 90B

Description

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.

Sample Input

Input
3 3
cba
bcd
cbc

Output
abcd

Input
5 5
fcofd
ooedo
afaoa
rdcdf
eofsf

Output

codeforces

#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<climits>
#include<string>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
using namespace std;
#define rep(i,j,k)for(i=j;i<k;i++)
#define per(i,j,k)for(i=j;i>k;i--)
#define MS(x,y)memset(x,y,sizeof(x))
#define max(a,b) a>b?a:b
#define min(a,b) a<b?a:b
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
typedef long long LL;
const int INF=0x7ffffff;
#define lson rt<<1, l, m
#define rson rt<<1|1, m+1, rconst int M=100+1;
char mp[M][M];
int flag[M][M];
int i,j,k,n,m;void cheak(int nn,int mm)
{for(int k=nn+1;k<n;k++){if(mp[k][mm]==mp[nn][mm])flag[k][mm]++,flag[nn][mm]++;}for(int k=mm+1;k<m;k++){if(mp[nn][k]==mp[nn][mm])flag[nn][k]++,flag[nn][mm]++;}return ;
}int main()
{scanf("%d%d",&n,&m);MS(flag,0);for(int i=0;i<n;i++)scanf("%s",mp[i]);for(int i=0;i<n;i++)for(int j=0;j<m;j++){cheak(i,j);}for(i=0;i<n;i++)for(j=0;j<m;j++)if(!flag[i][j])printf("%c",mp[i][j]);printf("\n");return 0;
}

CodeForces 90B African Crossword【模拟】相关推荐

  1. CodeForces - 1526D Kill Anton(模拟)

    题目链接:https://vjudge.net/problem/CodeForces-1526D 题目大意:给出一个只有四种字母组成的字符串 AAA,要求将其重排列 BBB,使得贡献最大.贡献指的是, ...

  2. Codeforces Gym 100286I iSharp 模拟

    原题地址:http://codeforces.com/gym/100286/attachments/download/2013/20082009-acmicpc-northeastern-europe ...

  3. Pyramid of Glasses CodeForces - 676B (dp,模拟)

    题目:新冠病毒肆虐了好几个月,彻底打乱了大家的学习和生活,终于在阳光明媚的某月,全球迎来了新冠抗战的顺利.为了庆祝全球协力共同抗疫的顺利,同学们准备了一场庆祝晚会,一起幻想以后美好的生活,他们用香槟酒 ...

  4. Codeforces 770D Draw Brackets! 模拟+中缀表达式

    http://codeforces.com/problemset/problem/770/D 我先找出每个括号'+'的位置和每个s[i]的高度 括号一定会出现[],就是s[i]='[' s[i+1]= ...

  5. CodeForces - 1141ESuperhero Battle简单模拟

    Superhero Battle 这道题卡了我一个多小时,最后也没有做出来,成功称为吊车尾... 思路什么的都没有问题,主要是,爆long long了,这个太可怕了,就因为一个中间变量忘记开longl ...

  6. codeforces#239_div2_B Garland 简单模拟

    题目地址:戳这里 题目大意:剪成花环,可以cut 但是不能粘贴--那么最多的方案就是,对每一种具体的颜色,第一字符串中出现的次数和第二个字符串中出现的次数取较小值. 先以为not obliged to ...

  7. CodeForces 158 B. Taxi(模拟)

    [题目链接]click here~~ [题目大意]n组团体去包车,每组团体的人数<=4,一辆车最多容纳4人,求所求车的数目最小 [解题思路]:思路见代码~~ // C #ifndef _GLIB ...

  8. CodeForces 148C Terse princess(模拟)

    太坑了...这题 #include<iostream> #include<cstdio> #include<algorithm> #include<cstdl ...

  9. Codeforces 90B-African Crossword

    African Crossword time limit per test 2 seconds memory limit per test 256 megabytes input standard i ...

最新文章

  1. java 头尾 队列_超详细的java集合讲解
  2. 华为鸿蒙osbeta多场景展示,华为发布鸿蒙系统:全场景分布式OS
  3. linux系统命令基础知识
  4. 网页性能优化01-精灵图利弊与应用场景
  5. 鲁迅散文——狗的驳诘
  6. Excel VBA - Workbook对象
  7. 【LeetCode笔记】207. 课程表(Java、图、BFS、队列)
  8. qt中生成并读取配置文件Ini
  9. 信息学奥赛一本通(1070:人口增长)
  10. command对象和DataReader的学习
  11. java 线程 原子性_深入理解Java多线程与并发框架——Java内存模型与原子性、可见性、有序性...
  12. tomcat 报错:Error occurred during initialization of VM
  13. 相对开音节java,L314 单音节词读音规则(二)-元音字母发音规则
  14. 二十三种设计模式[4] - 原型模式(Prototype Pattern)
  15. IT项目验收流程及说明
  16. matlab最小二乘法拟合原理,最小二乘法曲线拟合_原理及matlab实现
  17. 《曾国藩的正面与侧面》,历史成功学新传与耕读理想
  18. 使用Keras构建深度图像搜索引擎
  19. 计算机科学与技术3d仿真设计,三维仿真
  20. 政府信息化需求开启 OA办公系统平台化时代

热门文章

  1. 傅里叶变换(juce库实现信号的幅度谱分析,附源码)
  2. 为新机让路走降价路线的两部手机,市场竞争太激烈,旗舰机也扛不住
  3. MfgTool工具使用
  4. windows10 cmd命令行添加php环境变量无效问题解决
  5. 使用Fedora media writer制作的启动U盘找不到处理方法
  6. 十目监测系统:中国乔丹侵权案终审败诉,乔丹体育,再见
  7. p-value,p-adjust,q-value三者的定义与使用
  8. 810处理器鸿蒙系统,鸿蒙系统华为机9月发布,四摄+麒麟810处理器,售价2000元左右?...
  9. 《Robust Face Recognition via Sparse Representation》论文翻译
  10. tkinter 开发的 算卦小软件|python