codeforces 192 c
link: http://codeforces.com/contest/330/problem/C
broute force
but you must be careful about some tricks and think about all the instances
/*
ID: zypz4571
LANG: C++
TASK: 192c.cpp
*/ #include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cctype>
#include <algorithm>
#include <queue>
#include <deque>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <functional>
#include <fstream>
#include <iomanip>
#include <sstream>
#include <numeric>
#include <cassert>
#include <ctime> #define INF 0x3f3f3f3f
#define REP(i, n) for(int i=0;i<int(n);++i)
#define FOR(i, a, b) for(int i=int(a);i<int(b);++i)
#define DWN(i, b, a) for(int i=int(b-1);i>=int(a);--i)
#define REP_1(i, n) for(int i=1;i<=int(n);++i)
#define mid int m=(l+r)/2
using namespace std;
int a[][], rows[], cols[];
int main ( int argc, char *argv[] )
{
#ifndef ONLINE_JUDGE
freopen("in.txt", "r", stdin);
#endif
int n; cin>>n;
char ch;
getchar();
REP(i, n) {
REP(j, n) {
scanf("%c", &ch);
if (ch == '.') a[i][j] = ;
else a[i][j] = ;
}
getchar();
}
bool flaga = true, flagb = true;
vector<pair<int, int> > v;
// REP(i, n) { /*here is error */
// flag = false; /* can not judge like this */
// REP(j, n) { /* short of some instance */
// if (a[i][j] == 1) {
// v.push_back(make_pair(i+1,j+1)); flag = true;
// break;
// }
// }
// if (!flag) break;
// }
REP(i, n) {
REP(j, n) {
rows[i] += a[i][j];
cols[j] += a[i][j];
}
}
REP(i, n) {
if (!rows[i]) flaga = false;
if (!cols[i]) flagb = false;
}
if (!flaga && !flagb) cout<<"-1"<<endl;
else {
if (!flagb)
REP(i, n) {
REP(j, n) {
if (a[i][j] == ) {v.push_back(make_pair(i+, j+)); break;}
}
}
else
REP(j, n) {
REP(i, n) {
if (a[i][j] == ) {v.push_back(make_pair(i+, j+)); break;}
}
}
vector<pair<int, int> >::iterator it;
for (it = v.begin(); it != v.end(); ++it) {
cout << (*it).first<<' '<<(*it).second<<endl;
}
}
return EXIT_SUCCESS;
} /* ---------- end of function main ---------- */
I got a WA in the match. sad.....
codeforces 192 c的更多相关文章
- [Codeforces #192] Tutorial
Link: Codeforces #192 传送门 前两天由于食物中毒现在还要每天挂一天的水 只好晚上回来随便找套题做做找找感觉了o(╯□╰)o A: 看到直接大力模拟了 但有一个更简便的方法,复杂度 ...
- codeforces 192 D
link: http://codeforces.com/contest/330/problem/D The discription looks so long, but the problem is ...
- CodeForces Round 192 Div2
This is the first time I took part in Codeforces Competition.The only felt is that my IQ was contemp ...
- Codeforces Round #192 (Div. 1) C. Graph Reconstruction 随机化
C. Graph Reconstruction Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/3 ...
- Codeforces Round #192 (Div. 1) B. Biridian Forest 暴力bfs
B. Biridian Forest Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/329/pr ...
- Codeforces Round #192 (Div. 1) A. Purification 贪心
A. Purification Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/329/probl ...
- [Codeforces Round #192 (Div. 2)] D. Biridian Forest
D. Biridian Forest time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
- Codeforces Round #192 (Div. 2) (330B) B.Road Construction
题意: 要在N个城市之间修建道路,使得任意两个城市都可以到达,而且不超过两条路,还有,有些城市之间是不能修建道路的. 思路: 要将N个城市全部相连,刚开始以为是最小生成树的问题,其实就是一道简单的题目 ...
- Codeforces Round #192 (Div. 2) (330A) A. Cakeminator
题意: 如果某一行没有草莓,就可以吃掉这一行,某一列没有也可以吃点这一列,求最多会被吃掉多少块蛋糕. //cf 192 div2 #include <stdio.h> #include & ...
随机推荐
- Java中Scanner的用法
转载自: http://blog.csdn.net/pkbilly/article/details/3068912 Scanner是SDK1.5新增的一个类,可是使用该类创建一个对象.Scanner ...
- dhtmlxScheduler日历日程控件包括天视图,周视图,月视图,年视图和日程表视图
dhtmlxScheduler 是一个基于Web的类似于Outlook的日历日程控件. 它完全由javascript/js/css编写, 提供类似于MS Outlook Calendar, Apple ...
- 动态加载DLL函数GetProcAddress错误
GetLastError获取错误代码127,指代“找不到指定程序”. 解决: 转自:http://hi.baidu.com/violetwangy/item/c35b3b95ecf5374cf0421 ...
- 解决json跨域时错误:SyntaxError: invalid label
将数据做以下返回: $callback = $_GET['callback']; echo $callback.'('.json_encode(array('html'=>$html)).')' ...
- 学习js之类的使用
<script language="javascript">function Person(){ }Person.prototype={ name:null ...
- POJ 1185 炮兵阵地(经典的状态压缩DP)
题意:中文题. 思路,经典的状态压缩题目. 由于列长比较小,我们可以以行为阶段用状态压缩来做. 由于攻击只占两个格,这样从行的角度看,第i行的炮兵只与前i-1和前i-2行有关系.这样如果用j,k,l分 ...
- stm32的软件架构问题
1. 架构组成:程序代码分为四种结构a) 顺序执行代码定义:按照顺序逐行执行的代码优点:是思路简单,代码可靠不易被干扰.缺点:占用资源用途:只用来各种变量.函数的定义,硬件的初始化程序位置:main. ...
- Security Checklist (路由器安全checklist)
Security Checklist Website by Michael Horowitz Home | Introduction | Router Bugs | Security Che ...
- Ubuntu 14.10 下安装Ganglia监控集群
关于 Ganglia 软件,Ganglia是一个跨平台可扩展的,高性能计算系统下的分布式监控系统,如集群和网格.它是基于分层设计,它使用广泛的技术,如XML数据代表,便携数据传输,RRDtool用于数 ...
- 刷固件Layer1到手机FLASH(硬刷)
开头: 注意:本文章并不是做GSM 嗅探必须的,平时我们刷机叫软刷是刷到内存里面的,断电就消失了,这个是硬刷,刷到flash里面的,断电不消失,开机就运行的. 本文章经过作者实测可行,这只是单个应用程 ...