codeforces-545a Toy Cars (analogue)

Source: Internet
Author: User

"Topic link": Click here~~

"To the effect of the topic":

Give a n*n matrix, 1 only on the diagonal (because you can't hit yourself), 0 for no car in collision, 1 for the first car (horizontal axis) was crashed, 2 for the first J car (ordinate) was crashed, 3 for two cars have crashed. Ask which cars are intact.

Code:

/  * * problem:codeforces-545a * Running time:15ms  * complier:g++  * Author:herongwei * Create time:  7: 47 2015/9/17 Thursday * Count the number of 1 and 3 per line, and if either one of them, the car means it's broken. */  #include <stdio.h> #include <string.h> #include <iostream> #include <algorithm>using namespace std;typedef long long ll;const int N=1e5+100;const int inf= 0x7f7f7f7f;bool Ok[n];int Main () {    int t,n,m;    memset (ok,false,sizeof (OK));    scanf ("%d", &t);    for (int i=1, i<=t; ++i) {for        (int j=1; j<=t; ++j) {                int x;                scanf ("%d", &x);                if (x==1| | x==3)                    ok[i]=true;            }    }    int ans=0;    for (int i=1; i<=t; ++i) {        if (!ok[i]) ans++;    }     printf ("%d\n", ans);     for (int i=1; i<=t; ++i) {         if (!ok[i])            printf ("%d", I);     }     if (ans) puts ("");     return 0;}


Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

codeforces-545a Toy Cars (analogue)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.