zoukankan      html  css  js  c++  java
  • Codeforces Round #303 (Div. 2) A 水

    A. Toy Cars
    time limit per test
    1 second
    memory limit per test
    256 megabytes
    input
    standard input
    output
    standard output

    Little Susie, thanks to her older brother, likes to play with cars. Today she decided to set up a tournament between them. The process of a tournament is described in the next paragraph.

    There are n toy cars. Each pair collides. The result of a collision can be one of the following: no car turned over, one car turned over, both cars turned over. A car is good if it turned over in no collision. The results of the collisions are determined by an n × n matrix А: there is a number on the intersection of the і-th row and j-th column that describes the result of the collision of the і-th and the j-th car:

    •  - 1: if this pair of cars never collided.  - 1 occurs only on the main diagonal of the matrix.
    • 0: if no car turned over during the collision.
    • 1: if only the i-th car turned over during the collision.
    • 2: if only the j-th car turned over during the collision.
    • 3: if both cars turned over during the collision.

    Susie wants to find all the good cars. She quickly determined which cars are good. Can you cope with the task?

    Input

    The first line contains integer n (1 ≤ n ≤ 100) — the number of cars.

    Each of the next n lines contains n space-separated integers that determine matrix A.

    It is guaranteed that on the main diagonal there are  - 1, and  - 1 doesn't appear anywhere else in the matrix.

    It is guaranteed that the input is correct, that is, if Aij = 1, then Aji = 2, if Aij = 3, then Aji = 3, and if Aij = 0, then Aji = 0.

    Output

    Print the number of good cars and in the next line print their space-separated indices in the increasing order.

    Examples
    input
    3
    -1 0 0
    0 -1 1
    0 2 -1
    output
    2
    1 3
    input
    4
    -1 3 3 3
    3 -1 3 3
    3 3 -1 3
    3 3 3 -1
    output
    0

    题意:给你一个矩阵 描述n辆车之间的关系
    0 代表碰撞中都不会翻车
    1 代表碰撞中i翻车
    2 代表碰撞中j翻车
    3 代表碰撞中两辆车都翻车 求在什么情况下都不会翻车的车的数量并输出序号
    题解:模拟 把行列代表的车标记一下就可以了

     1 /******************************
     2 code by drizzle
     3 blog: www.cnblogs.com/hsd-/
     4 ^ ^    ^ ^
     5  O      O
     6 ******************************/
     7 //#include<bits/stdc++.h>
     8 #include<iostream>
     9 #include<cstring>
    10 #include<cstdio>
    11 #include<map>
    12 #include<algorithm>
    13 #include<queue>
    14 #include<cmath>
    15 #define ll __int64
    16 #define PI acos(-1.0)
    17 #define mod 1000000007
    18 using namespace std;
    19 int n;
    20 int exm;
    21 int a[105];
    22 int main()
    23 {
    24     scanf("%d",&n);
    25     memset(a,0,sizeof(a));
    26     for(int i=1; i<=n; i++)
    27     {
    28         for(int j=1; j<=n; j++)
    29         {
    30             scanf("%d",&exm);
    31             if(exm==1)
    32                 a[i]=1;
    33             if(exm==2)
    34                 a[j]=1;
    35             if(exm==3)
    36             {
    37                 a[i]=1;
    38                 a[j]=1;
    39             }
    40         }
    41     }
    42     int ans=0;
    43     for(int i=1; i<=n; i++)
    44     {
    45         if(a[i]==0)
    46             ans++;
    47     }
    48     cout<<ans<<endl;
    49     for(int i=1; i<=n; i++)
    50     {
    51         if(a[i]==0)
    52             cout<<i<<" ";
    53     }
    54     cout<<endl;
    55     return 0;
    56 }
  • 相关阅读:
    弹出窗口的几种方法
    FCKeditor2.2+ASP.NET2.0不完全攻略
    如何运用 Form 表单认证 ?
    DataGrid的多种格式化显示方法
    如何显示在线人数,和所在位置?? [转自作者:子扬]
    备份和恢复Active Directory
    如何在vs.net里调试脚本 《一》
    初学ASP.Net时一些备忘的东西
    ASP.NET在线用户列表精确版——解决用户意外退出在线列表无法及时更新问题
    小技巧(一)分离字符串string str="(1,10,100,1000,10000,)";
  • 原文地址:https://www.cnblogs.com/hsd-/p/5733425.html
Copyright © 2011-2022 走看看