QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#648904#313. Equation Mod 2gankingWA 1ms5756kbC++201.5kb2024-10-17 20:54:082024-10-17 20:54:08

Judging History

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

  • [2024-10-17 20:54:08]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5756kb
  • [2024-10-17 20:54:08]
  • 提交

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