CSES - Aalto Competitive Programming 2024 - wk12 - Wed - Results
Submission details
Task:Even Grid
Sender:Rasse
Submission time:2024-11-27 16:52:46 +0200
Language:C++ (C++17)
Status:READY
Result:
Test results
testverdicttime
#1ACCEPTED0.00 sdetails
#2ACCEPTED0.00 sdetails
#3ACCEPTED0.00 sdetails
#4ACCEPTED0.00 sdetails
#5ACCEPTED0.00 sdetails
#6ACCEPTED0.00 sdetails
#70.00 sdetails
#80.00 sdetails
#9ACCEPTED0.00 sdetails
#100.00 sdetails
#11ACCEPTED0.00 sdetails

Compiler report

input/code.cpp: In function 'void solve()':
input/code.cpp:82:23: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   82 |     for (int i = 0; i < probs.size(); i++)
      |                     ~~^~~~~~~~~~~~~~
input/code.cpp:88:23: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::vector<long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   88 |     for (int i = 0; i < res.size(); i++)
      |                     ~~^~~~~~~~~~~~
input/code.cpp:90:27: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   90 |         for (int j = 0; j < res[i].size(); j++)
      |                         ~~^~~~~~~~~~~~~~~

Code

#include <iostream>
#include <vector>
#include <array>
#include <string>
#include <algorithm>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <queue>
#include <climits>
#include <cmath>
#include <functional>
#include <type_traits>
#include <fstream>
#include <bitset>
#include <complex>
#include <iomanip>
#include <bits/stdc++.h>
 
#include <ext/pb_ds/assoc_container.hpp> // gcc only
template<typename T>
using ordered_set = __gnu_pbds::tree<T, __gnu_pbds::null_type, std::less<T>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;
 
#define int long long
using namespace std;
 
int p(int base, int power, int mod)
{
    if (power == 0)
        return 1;
    if (power % 2 == 0)
    {
        int r = p(base, power/2, mod);
        return (r*r) % mod;
    }
    else
        return (p(base, power-1, mod)*base) % mod;
}
 
int LCM(int a, int b)
{
    return (a / __gcd(a, b)) * b;
}
 
int mod = 1e9+7;
 
 
void solve()
{
    int n;
    cin >> n;

    vector<vector<int>> res(n, vector<int>(n, 0));

    vector<int> probs;
    vector<int> rows;

    string s;
    cin >> s;
    for (int i = 0; i < n; i++)
    {
        res[0][i] = s[i]-'0';
        if (i != 0 && s[i] != '0')
        {
            probs.push_back(i);
        }

    }
    for (int i = 1; i < n; i++)
    {
        string row;
        cin >> row;
        res[i][0] = row[0]-'0';
        if (row[0] != '0')
        {
            rows.push_back(i);
        }
    }

    int rIdx = 0;
    for (int i = 0; i < probs.size(); i++)
    {
        res[rows[rIdx]][probs[i]] = 1;
        rIdx++;
    }

    for (int i = 0; i < res.size(); i++)
    {
        for (int j = 0; j < res[i].size(); j++)
        {
            cout << res[i][j];
        }
        cout << '\n';
    }

    
} 
 
signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
 
    int t = 1;
 
    //cin >> t;
 
    for (int i = 0; i < t; i++)
    {
        solve();
        //cout.flush();
    }
}

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: ACCEPTED

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

correct output
11101
11101
11101
11101
00000

user output
11101
11000
10100
10001
00000

Test 5

Verdict: ACCEPTED

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

correct output
10111
10111
10111
00000
10111

user output
10111
10100
10010
00000
10001

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:

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

correct output
10100
10100
00000
10100
10100

user output
10100
10100
00000
10000
10000

Test 8

Verdict:

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

correct output
10100
10100
10100
00000
10100

user output
10100
10100
10000
00000
10000

Test 9

Verdict: ACCEPTED

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

correct output
1010000000
1010000000
0000000000
0000000000
0000000000
...

user output
1010000000
1010000000
0000000000
0000000000
0000000000
...
Truncated

Test 10

Verdict:

input
100
100010110100011000001111001110...

correct output
100010110100011000001111001110...

user output
100010110100011000001111001110...
Truncated

Test 11

Verdict: ACCEPTED

input
100
100100110000010110111101111101...

correct output
100100110000010110111101111101...

user output
100100110000010110111101111101...
Truncated