QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#214543 | #6552. Good and Lucky Matrices | ucup-team2112# | 0 | 0ms | 3440kb | C++20 | 1.8kb | 2023-10-14 20:56:24 | 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;
}
Details
Tip: Click on the bar to expand more detailed information
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]+"