Submission details
Task:Simplified Sudoku
Sender:henrikaalto
Submission time:2018-09-13 18:02:18 +0300
Language:C++
Status:READY
Result:ACCEPTED
Test results
testverdicttime
#1ACCEPTED0.01 sdetails
#2ACCEPTED0.02 sdetails
#3ACCEPTED0.02 sdetails
#4ACCEPTED0.03 sdetails
#5ACCEPTED0.02 sdetails
#6ACCEPTED0.04 sdetails
#7ACCEPTED0.02 sdetails
#8ACCEPTED0.02 sdetails
#9ACCEPTED0.01 sdetails
#10ACCEPTED0.02 sdetails

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:8:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(size_t i=0;i<n;i++){
                    ~^~
input/code.cpp:9:25: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(size_t j=0;j<n;j++){
                        ~^~
input/code.cpp:15:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(size_t i=0;i<n;i++){
                    ~^~
input/code.cpp:18:25: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(size_t j=0;j<n;j++){
                        ~^~
input/code.cpp:23:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(size_t i=0;i<n;i++){
                    ~^~
input/code.cpp:26:25: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(size_t j=0;j<n...

Code

#include<iostream>

int main(){
    std::cin.tie(NULL);std::ios_base::sync_with_stdio(false);
    int n; std::cin>>n;
    int v[n][n];
    int a;
    for(size_t i=0;i<n;i++){
        for(size_t j=0;j<n;j++){
            std::cin>>a;v[i][j]=a;
        }
    }
    int rowsum=((n+1)*n)/2,temp;
    bool t=0;
    for(size_t i=0;i<n;i++){
        if(t){break;}
        temp=0;
        for(size_t j=0;j<n;j++){
            temp+=v[i][j];
        }
        if(!(temp==rowsum)){t=1;}
    }
    for(size_t i=0;i<n;i++){
        if(t){break;}
        temp=0;
        for(size_t j=0;j<n;j++){
            temp+=v[j][i];
        }
        if(!(temp==rowsum)){t=1;}
    }
    if(t){std::cout<<"NO";}
    else{std::cout<<"YES";}
}

Test details

Test 1

Verdict: ACCEPTED

input
1
1

correct output
YES

user output
YES

Test 2

Verdict: ACCEPTED

input
2
1 2
2 1

correct output
YES

user output
YES

Test 3

Verdict: ACCEPTED

input
2
1 1
1 1

correct output
NO

user output
NO

Test 4

Verdict: ACCEPTED

input
2
2 2
2 2

correct output
NO

user output
NO

Test 5

Verdict: ACCEPTED

input
2
1 2
1 2

correct output
NO

user output
NO

Test 6

Verdict: ACCEPTED

input
2
1 2
1 1

correct output
NO

user output
NO

Test 7

Verdict: ACCEPTED

input
100
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

correct output
NO

user output
NO

Test 8

Verdict: ACCEPTED

input
100
32 84 70 64 50 82 33 91 77 56 ...

correct output
NO

user output
NO

Test 9

Verdict: ACCEPTED

input
100
1 2 3 4 5 6 7 8 9 10 11 12 13 ...

correct output
YES

user output
YES

Test 10

Verdict: ACCEPTED

input
100
1 2 3 4 5 6 7 8 9 10 11 12 13 ...

correct output
NO

user output
NO