zoukankan      html  css  js  c++  java
  • 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

     1 /*
     2 ID: zypz4571
     3 LANG: C++
     4 TASK: 192c.cpp
     5  */
     6 
     7 #include <iostream>
     8 #include <cstdio>
     9 #include <cstdlib>
    10 #include <cstring>
    11 #include <cmath>
    12 #include <cctype>
    13 #include <algorithm>
    14 #include <queue>
    15 #include <deque>
    16 #include <queue>
    17 #include <list>
    18 #include <map>
    19 #include <set>
    20 #include <vector>
    21 #include <utility>
    22 #include <functional>
    23 #include <fstream>
    24 #include <iomanip>
    25 #include <sstream>
    26 #include <numeric>
    27 #include <cassert>
    28 #include <ctime>
    29 
    30 #define INF 0x3f3f3f3f
    31 #define REP(i, n) for(int i=0;i<int(n);++i)
    32 #define FOR(i, a, b) for(int i=int(a);i<int(b);++i)
    33 #define DWN(i, b, a) for(int i=int(b-1);i>=int(a);--i)
    34 #define REP_1(i, n) for(int i=1;i<=int(n);++i)
    35 #define mid int m=(l+r)/2
    36 using namespace std;
    37 int a[102][102], rows[102], cols[102];
    38 int main ( int argc, char *argv[] )
    39 {
    40 #ifndef ONLINE_JUDGE
    41 freopen("in.txt", "r", stdin);
    42 #endif
    43     int n; cin>>n;
    44     char ch;
    45     getchar();
    46     REP(i, n) {
    47         REP(j, n) {
    48             scanf("%c", &ch);
    49             if (ch == '.') a[i][j] = 1;
    50             else a[i][j] = 0;
    51         }
    52         getchar();
    53     }
    54     bool flaga = true, flagb = true;
    55     vector<pair<int, int> > v;
    56 //    REP(i, n) {                                 /*here is error */
    57 //        flag = false;                             /* can not judge like this */
    58 //        REP(j, n) {                               /* short of some instance */
    59 //            if (a[i][j] == 1) {
    60 //                v.push_back(make_pair(i+1,j+1)); flag = true;
    61 //                break;
    62 //            }
    63 //        }
    64 //        if (!flag) break;
    65 //    }
    66     REP(i, n) {
    67         REP(j, n) {
    68             rows[i] += a[i][j]; 
    69             cols[j] += a[i][j];
    70         }
    71     }
    72     REP(i, n) {
    73         if (!rows[i]) flaga = false;
    74         if (!cols[i]) flagb = false;
    75     }
    76     if (!flaga && !flagb) cout<<"-1"<<endl;
    77     else {
    78         if (!flagb)
    79         REP(i, n) {
    80             REP(j, n) {
    81                 if (a[i][j] == 1) {v.push_back(make_pair(i+1, j+1)); break;}
    82             }
    83         }
    84         else 
    85         REP(j, n) {
    86             REP(i, n) {
    87                 if (a[i][j] == 1) {v.push_back(make_pair(i+1, j+1)); break;}
    88             }
    89         }
    90         vector<pair<int, int> >::iterator it;
    91         for (it = v.begin(); it != v.end(); ++it) {
    92             cout << (*it).first<<' '<<(*it).second<<endl;
    93         }
    94     }
    95         return EXIT_SUCCESS;
    96 }                /* ----------  end of function main  ---------- */

    I got a WA in the match. sad.....

  • 相关阅读:
    安卓代码混淆与反射冲突,地图无法显示等问题解决及反编译方法
    脱掉360奇虎的“加固保”壳后的发现与你的微信安全
    android 发送http请求
    mysql sql优化
    hdu 1548 A strange lift
    【转】vc中使用SendMessage正确发送自定义消息的方法--不错
    【转】各种常用浏览器“兼容性视图”设置方法
    IE 弹出"Unable to do xml/xsl" Processing
    【转】MFC界面更新实现方法
    【转】怎么在Foxmail回复/转发时使用签名?
  • 原文地址:https://www.cnblogs.com/liuxueyang/p/3204599.html
Copyright © 2011-2022 走看看