Submission details
Task:Even Grid
Sender:Isak
Submission time:2025-11-26 17:19:01 +0200
Language:C++ (C++20)
Status:READY
Result:
Test results
testverdicttime
#1ACCEPTED0.00 sdetails
#2ACCEPTED0.00 sdetails
#3ACCEPTED0.00 sdetails
#40.00 sdetails
#50.00 sdetails
#6ACCEPTED0.00 sdetails
#7ACCEPTED0.00 sdetails
#8ACCEPTED0.00 sdetails
#9ACCEPTED0.00 sdetails
#100.00 sdetails
#110.00 sdetails

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:36:19: warning: ignoring return value of '__ssize_t getline(char**, size_t*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   36 |     (void) getline(&line, &size, stdin);
      |            ~~~~~~~^~~~~~~~~~~~~~~~~~~~~
input/code.cpp:43:23: warning: ignoring return value of '__ssize_t getline(char**, size_t*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   43 |         (void) getline(&line, &size, stdin);
      |                ~~~~~~~^~~~~~~~~~~~~~~~~~~~~

Code

#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>

#define LOOP(i,s,e) for (uint64_t i = (s); i < (e); i++)
#define SCAN(...) if (scanf(__VA_ARGS__) == 0) return EXIT_FAILURE

void pr(bool b){
    if (b)
        printf("1");
    else
        printf("0");
}

uint64_t find_first(bool *r, uint64_t s){
    uint64_t i = s;
    while (! r[i])
        i++;
    return i;
}

int main() {
    uint64_t n = 0;
    SCAN("%ld\n", &n);

    // main algo

    bool row[n];
    bool collumn[n];
    collumn[0] = true;
    char *line = NULL;
    size_t size;
    (void) getline(&line, &size, stdin);
    // printf("line : --%s--\n", line);
    LOOP(i, 0, n){
        row[i] = (line[i] == '1') ? true : false;
    }

    LOOP(i, 1, n){
        (void) getline(&line, &size, stdin);
        // printf("line : --%s--\n", line);
        collumn[i] = (line[0] == '1') ? true : false;
    }

    LOOP(i, 0, n){
        pr(row[i]);
    }
    printf("\n");
    uint64_t next = 1;
    LOOP(i, 1, n){
        pr(collumn[i]);
        if (! collumn[i]){ // 0
            LOOP(j, 1, n){
                pr(false);
            }
        } else { // 1
            next = find_first(row, next);
            LOOP(j, 1, n){
                pr(j==next);
            }
        }
        printf("\n");
    }

    return EXIT_SUCCESS;
}

Test details

Test 1

Verdict: ACCEPTED

input
2
11
1?

correct output
11
11

user output
11
11

Test 2

Verdict: ACCEPTED

input
3
101
1??
0??

correct output
101
101
000

user output
101
101
000

Test 3

Verdict: ACCEPTED

input
4
1010
0???
1???
0???

correct output
1010
0000
1010
0000

user output
1010
0000
1010
0000

Test 4

Verdict:

input
5
11101
1????
1????
1????
...

correct output
11101
11101
11101
11101
00000

user output
11101
11000
11000
11000
00000

Test 5

Verdict:

input
5
10111
1????
1????
0????
...

correct output
10111
10111
10111
00000
10111

user output
10111
10100
10100
00000
10100

Test 6

Verdict: ACCEPTED

input
5
11000
0????
0????
0????
...

correct output
11000
00000
00000
00000
11000

user output
11000
00000
00000
00000
11000

Test 7

Verdict: ACCEPTED

input
5
10100
1????
0????
1????
...

correct output
10100
10100
00000
10100
10100

user output
10100
10100
00000
10100
10100

Test 8

Verdict: ACCEPTED

input
5
10100
1????
1????
0????
...

correct output
10100
10100
10100
00000
10100

user output
10100
10100
10100
00000
10100

Test 9

Verdict: ACCEPTED

input
10
1010000000
1?????????
0?????????
0?????????
...

correct output
1010000000
1010000000
0000000000
0000000000
0000000000
...

user output
1010000000
1010000000
0000000000
0000000000
0000000000
...

Test 10

Verdict:

input
100
100010110100011000001111001110...

correct output
100010110100011000001111001110...

user output
100010110100011000001111001110...

Test 11

Verdict:

input
100
100100110000010110111101111101...

correct output
100100110000010110111101111101...

user output
100100110000010110111101111101...