QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#648904 | #313. Equation Mod 2 | ganking | WA | 1ms | 5756kb | C++20 | 1.5kb | 2024-10-17 20:54:08 | 2024-10-17 20:54:08 |
Judging History
answer
#include<bits/stdc++.h>
#define fo(i,a,b) for (ll (i)=(a);(i)<=(b);(i)++)
#define fd(i,b,a) for (ll (i)=(b);(i)>=(a);(i)--)
#define eb emplace_back
#define pi pair<ll,ll>
#define mk(x,y) make_pair((x),(y))
#define lc (o<<1)
#define rc ((o<<1)|1)
#define fi first
#define se second
using namespace std;
typedef long long ll;
const ll inf = 1ll << 60;
const int N = 5e5 + 10;
const ll mo = 998244353;
bitset<5005> a[N];
int n, m;
ll x[N];
int main()
{
// freopen("data.in", "r", stdin);
// freopen("data.out", "w", stdout);
ios::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
int z;
cin >> n >> m;
fo(i, 1, n) x[i] = 1;
fo(i, 1, m) {
fo(j, 1, n + 1) {
cin >> z;
a[i][j] = z;
}
}
int now = 1;
fo(i, 1, min(n, m)) {
fo(j, now + 1, m) if (a[j][i]) swap(a[now], a[j]);
if (!a[now][i]) continue;
fo(j, 1, m) if (a[j][i] && j != now) a[j] ^= a[now];
now++;
}
int pos;
fd(i, m, 1) {
pos = -1;
fo(j, 1, n) {
if (a[i][j]) {
pos = j; break;
}
}
fo(j, pos + 1, n) {
if (a[i][j]) {
if (x[j] < 0) {
x[j] = 0;
}
else {
a[i][n + 1] = a[i][n + 1] ^ x[j];
}
}
}
if (pos > 0) x[pos] = a[i][n + 1];
}
fo(i, 1, n) cout << max(0ll, x[i]) << " ";
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 5708kb
input:
100 95 0 0 0 1 1 0 1 1 1 0 0 1 0 1 1 0 0 1 1 0 1 0 1 0 0 0 1 1 0 1 1 1 0 1 0 1 0 0 0 0 1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