African Crossword
time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

standard output

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 3
cba
bcd
cbc

output
abcd

input
5 5
fcofd
ooedo
afaoa
rdcdf
eofsf

output
codeforces

题意:给定一个字符矩阵,对于某个字符如果在同行或者同列有相同的字符出现,那么这个字符被标记,最后从上到下、从左到右输出所有未标记字符。

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>using namespace std;char ch[105][105];
int visit[105][105];
int n,m;int check(int x,int y)
{int flag=0;for(int i=0;i<n;i++)if(i!=x&&ch[x][y]==ch[i][y]) visit[i][y]=1,flag=1;for(int i=0;i<m;i++)if(i!=y&&ch[x][y]==ch[x][i]) visit[x][i]=1,flag=1;return flag;
}int main()
{while(~scanf("%d %d",&n,&m)){memset(visit,0,sizeof visit);for(int i=0;i<n;i++)scanf("%s",ch[i]);for(int i=0;i<n;i++){for(int j=0;j<m;j++){int ans=check(i,j);if(ans) visit[i][j]=1;}}for(int i=0;i<n;i++){for(int j=0;j<m;j++)if(!visit[i][j]) printf("%c",ch[i][j]);}printf("\n");}return 0;
}

Codeforces 90B-African Crossword相关推荐

  1. CodeForces 90B African Crossword【模拟】

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

  2. 【codeforces 721A】One-dimensional Japanese Crossword

    A. One-dimensional Japanese Crossword time limit per test 1 second memory limit per test 256 megabyt ...

  3. 【Codeforces】 Round #374 (Div. 2)

    Position:http://codeforces.com/contest/721 我的情况 开始还是rank1,秒出C.(11:00机房都走光了,我ma到11:05才走,只打了一个小时) 结果.. ...

  4. Codeforces Round #374 (Div. 2) A. One-dimensional Japanese Crosswor 水题

    A. One-dimensional Japanese Crossword 题目连接: http://codeforces.com/contest/721/problem/A Description ...

  5. 【Codeforces】A2组刷题记录(50 / 50)完结

    目录 A1. Counterexample A2. Good Number A3. Dice Tower ★A4. Alyona and Numbers A5. Mountain Scenery rz ...

  6. Educational Codeforces Round 105 (Rated for Div. 2) 题解

    Educational Codeforces Round 105 (Rated for Div. 2) A. ABC String 枚举ABC分别为"( "和 " )&q ...

  7. CodeForces 375D Tree and Queries

    传送门:https://codeforces.com/problemset/problem/375/D 题意: 给你一颗有根树,树上每个节点都有其对应的颜色,有m次询问,每次问你以点v为父节点的子树内 ...

  8. 「日常训练」Bad Luck Island(Codeforces Round 301 Div.2 D)

    题意与分析(CodeForces 540D) 是一道概率dp题. 不过我没把它当dp做... 我就是凭着概率的直觉写的,还好这题不算难. 这题的重点在于考虑概率:他们喜相逢的概率是多少?考虑超几何分布 ...

  9. 【codeforces 812C】Sagheer and Nubian Market

    [题目链接]:http://codeforces.com/contest/812/problem/C [题意] 给你n个物品; 你可以选购k个物品;则 每个物品有一个基础价值; 然后还有一个附加价值; ...

最新文章

  1. Notepad++快捷键使用技巧
  2. leetcode算法题--划分为k个相等的子集★
  3. 在使用angularjs过程,ng-repeat中track by的作用
  4. linux给文件加可执行权限
  5. VC多线程编程之线程创建与示例
  6. DataList:HTML5中的input输入框自动提示宝器
  7. python3.6串口编程实例_使用python3实现操作串口详解
  8. Windows 平台下安装Cygwin后,sshd服务无法启动
  9. 【扩展KMP】【HDU 4333】Revolving Digits
  10. python flask 分页_python flask实现分页效果
  11. 人类微笑表情识别(HOG算法)
  12. Java基础知识点汇总
  13. 计算机开机切换用户界面,win7开机登录界面怎么设置win7更换开机画面壁纸解决办法...
  14. CV520直接pin对pin替换 MS520,直接替换,无需修改硬件以及软件
  15. GHD官宣全新中国区焕发大使乔欣
  16. 什么是开源软件? 开源和FOSS解释
  17. 为你的TabBar添加Badge-感谢分享
  18. 仿QQ和飞秋并支持语音视频白板屏幕共享的即时聊天软件
  19. AirFlow_使用
  20. 【show me the code】Python练习题语法笔记 1

热门文章

  1. VIVO一面竟然翻车,十年Java编程开发生涯
  2. Rundeck使用指南
  3. C++字符类型总结区别wchar_t,char,WCHAR
  4. c盘瘦身好帮手 mklink
  5. 中国无缘Windows 8盒装版 .
  6. 获取url地址的方法
  7. Postman调用grpc接口
  8. 联发科高端梦断vivo手,天玑1000被用于中端手机
  9. python实现直播功能rtmo_基于python的直播间接口测试实战 详解结合项目
  10. python中类的函数的调用