Codeforces Round #192 (Div. 1) A. Purification(贪心模拟+清除每行每列)
来源:互联网 发布:解压软件 mac 编辑:程序博客网 时间:2024/05/29 08:03
题目链接
题意:给出一个n*n的矩阵,你可以在’.’位置放魔法,魔法会使该行该列的‘E’变为’.’。如果可以全部清空输出n行,每行表示每次的释放魔法点。否则输出-1
解答:贪心模拟、
#include<bits/stdc++.h>using namespace std;#define LL long long#define pb push_back#define X first#define Y second#define cl(a,b) memset(a,b,sizeof(a))typedef pair<int,int> P;const int maxn=105;const LL inf=1<<27;char a[maxn][maxn];int main(){ int n;scanf("%d",&n); for(int i=0;i<n;i++){ scanf("%s",a[i]); } bool ok1,ok2; int i=0,j=0; for(i=0;i<n;i++){ ok1=false; for(j=0;j<n;j++)if(a[i][j]=='.'){ break; } if(j==n){ok1=true;break;} } for(j=0;j<n;j++){ ok2=false; for(i=0;i<n;i++)if(a[i][j]=='.'){ break; } if(i==n){ok2=true;break;} } if(ok1&&ok2){ puts("-1");return 0; } if(!ok1){ for(int i=0;i<n;i++){ for(int j=0;j<n;j++){ if(a[i][j]=='.'){ printf("%d %d\n",i+1,j+1);break; } } } return 0; } if(!ok2){ for(i=0;i<n;i++){ for(j=0;j<n;j++)if(a[j][i]=='.'){ printf("%d %d\n",j+1,i+1);break; } } } return 0;}
0 0
- Codeforces Round #192 (Div. 1) A. Purification(贪心模拟+清除每行每列)
- Codeforces Round #192 (Div. 2) (329A)C.Purification
- Codeforces Round #192 (Div. 2) C. Purification
- Codeforces Round #334 (Div. 2)-More Cowbell(贪心模拟)
- Codeforces Round #340 (Div. 2)(C)贪心,模拟
- Codeforces Round #346 (Div. 2) -A. Round House(模拟)
- Divide by Zero 2017 and Codeforces Round #399 (Div. 1 + Div. 2, combined) A(贪心)
- Codeforces Round #194 (Div. 1) / 333A Secrets(贪心)
- Codeforces Round #282 (Div. 1) A. Treasure (贪心)
- Codeforces Round #260 (Div. 2) A (贪心)
- Codeforces Round #111 (Div. 2) A Twins (贪心)
- Codeforces Round #279 (Div. 2)---A. Team Olympiad (贪心)
- Codeforces Round #303 (Div. 2) A - Equidistant String(贪心)
- Codeforces Round #202 (Div. 2)(A)贪心
- Codeforces Round #311 (Div. 2)(A)贪心
- Codeforces Round #342 (Div. 2)(A)贪心,数学
- Codeforces Round #438 (Div. 1 + Div. 2 combined) A. Bark to Unlock(模拟)
- Codeforces 329A Purification
- 1012 the Best Rank
- Android Event.getX 与getRawX的区别
- 1083 List Grades
- 红黑树的插入C实现
- 【小松教你手游开发】【unity实用技能】unity 内存调试方法
- Codeforces Round #192 (Div. 1) A. Purification(贪心模拟+清除每行每列)
- 栈的顺序
- 操作系统的历史 History of OS part 1
- 1093 count PAT's
- CAShapeLayer
- 记录学习python装饰器
- 成长编码1
- 1100 Mars Numbers
- 其他权限管理命令