Codeforces 90B-African Crossword
2 seconds
256 megabytes
standard input
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.
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.
Print the encrypted word on a single line. It is guaranteed that the answer consists of at least one letter.
3 3 cba bcd cbc
abcd
5 5 fcofd ooedo afaoa rdcdf eofsf
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相关推荐
- CodeForces 90B African Crossword【模拟】
African Crossword Time Limit:2000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u ...
- 【codeforces 721A】One-dimensional Japanese Crossword
A. One-dimensional Japanese Crossword time limit per test 1 second memory limit per test 256 megabyt ...
- 【Codeforces】 Round #374 (Div. 2)
Position:http://codeforces.com/contest/721 我的情况 开始还是rank1,秒出C.(11:00机房都走光了,我ma到11:05才走,只打了一个小时) 结果.. ...
- Codeforces Round #374 (Div. 2) A. One-dimensional Japanese Crosswor 水题
A. One-dimensional Japanese Crossword 题目连接: http://codeforces.com/contest/721/problem/A Description ...
- 【Codeforces】A2组刷题记录(50 / 50)完结
目录 A1. Counterexample A2. Good Number A3. Dice Tower ★A4. Alyona and Numbers A5. Mountain Scenery rz ...
- Educational Codeforces Round 105 (Rated for Div. 2) 题解
Educational Codeforces Round 105 (Rated for Div. 2) A. ABC String 枚举ABC分别为"( "和 " )&q ...
- CodeForces 375D Tree and Queries
传送门:https://codeforces.com/problemset/problem/375/D 题意: 给你一颗有根树,树上每个节点都有其对应的颜色,有m次询问,每次问你以点v为父节点的子树内 ...
- 「日常训练」Bad Luck Island(Codeforces Round 301 Div.2 D)
题意与分析(CodeForces 540D) 是一道概率dp题. 不过我没把它当dp做... 我就是凭着概率的直觉写的,还好这题不算难. 这题的重点在于考虑概率:他们喜相逢的概率是多少?考虑超几何分布 ...
- 【codeforces 812C】Sagheer and Nubian Market
[题目链接]:http://codeforces.com/contest/812/problem/C [题意] 给你n个物品; 你可以选购k个物品;则 每个物品有一个基础价值; 然后还有一个附加价值; ...
最新文章
- Notepad++快捷键使用技巧
- leetcode算法题--划分为k个相等的子集★
- 在使用angularjs过程,ng-repeat中track by的作用
- linux给文件加可执行权限
- VC多线程编程之线程创建与示例
- DataList:HTML5中的input输入框自动提示宝器
- python3.6串口编程实例_使用python3实现操作串口详解
- Windows 平台下安装Cygwin后,sshd服务无法启动
- 【扩展KMP】【HDU 4333】Revolving Digits
- python flask 分页_python flask实现分页效果
- 人类微笑表情识别(HOG算法)
- Java基础知识点汇总
- 计算机开机切换用户界面,win7开机登录界面怎么设置win7更换开机画面壁纸解决办法...
- CV520直接pin对pin替换 MS520,直接替换,无需修改硬件以及软件
- GHD官宣全新中国区焕发大使乔欣
- 什么是开源软件? 开源和FOSS解释
- 为你的TabBar添加Badge-感谢分享
- 仿QQ和飞秋并支持语音视频白板屏幕共享的即时聊天软件
- AirFlow_使用
- 【show me the code】Python练习题语法笔记 1