CSES - Practice Contest 2024 - Results
Submission details
Task:Judge correctness
Sender:asdf
Submission time:2024-09-28 16:22:03 +0300
Language:C++ (C++20)
Status:READY
Result:
Test results
testverdicttime
#1ACCEPTED0.03 sdetails
#2ACCEPTED1.29 sdetails
#32.40 sdetails
#40.20 sdetails
#50.20 sdetails
#60.20 sdetails
#70.20 sdetails
#80.20 sdetails
#90.20 sdetails
#100.20 sdetails

Compiler report

In file included from /usr/include/c++/11/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:33,
                 from input/code.cpp:1:
input/code.cpp: In constructor 'Matrix::Matrix(const std::vector<std::vector<int> >&)':
input/code.cpp:30:47: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   30 |         /**/ for (auto x : d) assert(x.size() == size);
      |                                      ~~~~~~~~~^~~~~~~

Code

#include <bits/stdc++.h>
using namespace std;

using type = int; // Kiểu dữ liệu các phần tử của ma trận

struct Matrix {
    vector <vector <type> > data;

    // Số lượng hàng của ma trận
    int row() const { return data.size(); }

    // Số lượng hàng của ma trận
    int col() const { return data[0].size(); }

    auto & operator [] (int i) { return data[i]; }

    const auto & operator[] (int i) const { return data[i]; }

    Matrix() = default;

    Matrix(int r, int c): data(r, vector <type> (c)) { }

    Matrix(const vector <vector <type> > &d): data(d) {

        // Kiểm tra các hàng có cùng size không và size có lớn hơn 0 hay không
        // Tuy nhiên không thực sự cần thiết, ta có thể bỏ các dòng /**/ đi
        /**/ assert(d.size());
        /**/ int size = d[0].size();
        /**/ assert(size);
        /**/ for (auto x : d) assert(x.size() == size);
    }

    // In ra ma trận.
    friend ostream & operator << (ostream &out, const Matrix &d) {
        for (auto x : d.data) {
            for (auto y : x) out << y << ' ';
            out << '\n';
        }
        return out;
    }

    Matrix operator - (const Matrix &b) {
        Matrix a = *this;
        assert(a.col() == b.col());
        assert(a.row() == b.row());
        Matrix c(a.row(), a.col());
        for (int i = 0; i < a.row(); i++) {
            for (int j = 0; j < a.col(); j++) {
                c[i][j] = (a[i][j] - b[i][j] + 64) % 64;
            }
        }
        return c;
    }

    // Nhân ma trận
    Matrix operator * (const Matrix &b) {
        Matrix a = *this;

        // Kiểm tra điều kiện nhân ma trận
        assert(a.col() == b.row());

        Matrix c(a.row(), b.col());
        for (int i = 0; i < a.row(); ++i)
            for (int j = 0; j < b.col(); ++j)
                for (int k = 0; k < a.col(); ++k) {
                    c[i][j] += (a[i][k] % 64) * (b[k][j] % 64);
                    c[i][j] %= 64;
                }
        return c;
    }
};

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int Rand(int l, int r) { return uniform_int_distribution<int>(l, r)(rng); }

const int N = 5005;

int n;

int decode(char c) {
    if (isupper(c)) return c - 'A';
    if (islower(c)) return 26 + c - 'a';
    if (isdigit(c)) return 52 + c - '0';
    if (c == '+') return 62;
    return 63; 
}

void solve() {
    cin >> n;
    Matrix a(n, n), at(n, n), x(n, n);
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            char c;
            cin >> c;
            a[i][j] = decode(c);
            at[j][i] = decode(c);
        }
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            char c;
            cin >> c;
            x[i][j] = decode(c);
        }
    }

    int ite = 8;
    bool correct = true;
    while (ite--) {
        Matrix v(n, 1);
        for (int i = 0; i < n; i++) v[i][0] = Rand(0, 1);

        Matrix p = (a * (at * v)) - (x * v);

        for (int i = 0; i < n; i++) {
            if (p[i][0]) {
                correct = false;
                break;
            }
        }

        if (!correct) break;
    }

    cout << correct << '\n';
}

signed main() {
    cin.tie(0)->sync_with_stdio(0);

    int t;
    cin >> t;

    while (t--) {
        solve();
    }
}

Test details

Test 1

Verdict: ACCEPTED

input
500
12
N49lyQuAZh1l
PwNJA+wuTBr+
HO09lJg8kbup
...

correct output
0
0
1
1
1
...

user output
0
0
1
1
1
...
Truncated

Test 2

Verdict: ACCEPTED

input
3
666
OvHf9jpB0RViia/ZD3gRQ7o1FELYh3...

correct output
0
0
1

user output
0
0
1

Test 3

Verdict:

input
2
517
RWVknnH+hL6AfeKFbOu6OuAJL9dvLw...

correct output
0
1

user output
(empty)

Test 4

Verdict:

input
1
5000
QP9pS1MOq6eDDKGQh//TrJUIvbM53a...

correct output
0

user output
(empty)

Test 5

Verdict:

input
1
5000
RSX7ZuQE6A94s8s+9oP1uCDHRkmZ+7...

correct output
1

user output
(empty)

Test 6

Verdict:

input
1
5000
b0V0j4vQ8CeiJrcUk2yssPF1B9EEDb...

correct output
1

user output
(empty)

Test 7

Verdict:

input
1
5000
VLdpW71f4Cdr+xdCRlwmAnNfMjqwMU...

correct output
0

user output
(empty)

Test 8

Verdict:

input
1
5000
kBZaGETPWmyNR4NCvCPbJnvq2+JBfP...

correct output
0

user output
(empty)

Test 9

Verdict:

input
1
5000
PES9AhJn+FZBVO5gqRLYbavSvaDUfU...

correct output
0

user output
(empty)

Test 10

Verdict:

input
1
5000
EoXwgdrAtKtV4M7jn0jAkNwkJX+be9...

correct output
1

user output
(empty)