QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#214543#6552. Good and Lucky Matricesucup-team2112#0 0ms3440kbC++201.8kb2023-10-14 20:56:242023-10-14 20:56:24

Judging History

你现在查看的是最新测评结果

  • [2023-10-14 20:56:24]
  • 评测
  • 测评结果:0
  • 用时:0ms
  • 内存:3440kb
  • [2023-10-14 20:56:24]
  • 提交

answer

#include <bits/stdc++.h>

std::bitset<2001> bs[2001];

void solve(){
    int n;
    std::string s;
    std::cin >> s >> n;
    int o = s != "lucky";
    for (int i = 0; i < n; i += 1) {
        std::string t;
        std::cin >> t;
        for (int j = 0; j < n; j += 1) {
            bs[i][j] = t[j] - '0';
        }
    }
    std::vector<std::tuple<int, int, int> > op;
    for (int i = 0; i < n; i += 1) {
        if (bs[i][i] == 0) {
            for (int j = i + 1; j < n; j += 1) {
                if (bs[j][i] == 1) {
                    op.emplace_back(0, i, j);
                    std::swap(bs[i], bs[j]);
                    break;
                }
            }
        }
        
        for (int j = i + 1; j < n; j += 1) {
            if (bs[j][i] == 1) {
                op.emplace_back(1, i, j);
                if (o == 0) {
                    bs[j][i] = 0;
                }
                else {
                    bs[j] ^= bs[i];
                }
            }
        }
    }
    while (not op.empty()) {
        auto [t, i, j] = op.back();
        op.pop_back();
        if (t == 0) {
            std::swap(bs[i], bs[j]);
        }
        else {
            if (o == 0) {
                bs[j] ^= bs[i];
            }
            else {
                bs[j][i] = 1;
            }
        }
    }
    std::cout << n << "\n";
    for (int i = 0; i < n; i += 1) {
        for (int j = 0; j < n; j += 1) {
            std::cout << bs[i][j];
        }
        std::cout << "\n";
    }
    std::cout << std::endl;
}

int main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    int T;
    std::cin >> T;
    while(T--) {
        solve();
    }
    return 0;
}

详细

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3440kb

First Run Input

3
lucky
2
11
11
good
2
11
01
lucky
2
01
10

First Run Output

2
11
10

2
11
01

2
01
10


Second Run Input

3
good
2
11
10
lucky
2
11
01
good
2
01
10

Second Run Output

2
11
11

2
11
01

2
01
10


result:

wrong answer Line [name=line] equals to "", doesn't correspond to pattern "[-,0-9]+"