QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#593080 | #9319. Bull Farm | arca | WA | 71ms | 6044kb | C++23 | 2.5kb | 2024-09-27 11:29:25 | 2024-09-27 11:29:25 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define endl "\n"
#ifndef ONLINE_JUDGE
#include "../../../debug.h"
#endif
#define FOR(i, a, b) for (int i = a; i <= b; i++)
#define ROF(i, a, b) for (int i = a; i >= b; i--)
/* ============================ CONFIG BEGIN ============================ */
constexpr int N = 2005;
constexpr int Q = 1e6 + 5;
bitset<N> G[N], vis[N];
int t[N];
vector<array<int, 3>> qlist[N];
vector<array<int, 2>> elist[N];
bitset<N> inq[N];
int ans[Q];
int buc[N];
int n, l, q;
queue<pair<int, int>> Queue;
int input() {
char a, b;
cin >> a >> b;
return (a - 48) * 50 + (b - 48);
}
void pushqueue(int u, int v) {
if (!inq[u].test(v)) {
Queue.push({u, v});
inq[u].set(v);
}
}
void work(int u, int v) {
G[u].set(v);
auto newE = G[u];
G[u] |= G[v];
newE ^= G[u];
while (1) {
int w = newE._Find_first();
if (w < 1 or w > n) break;
pushqueue(u, w);
newE.flip(w);
}
}
void add(int u, int v) {
if (G[u].test(v)) return;
pushqueue(u, v);
while (!Queue.empty()) {
auto [u, v] = Queue.front();
Queue.pop();
work(u, v);
}
}
/* ============================= CONFIG END ============================= */
void solve() {
cin >> n >> l >> q;
FOR(id, 1, l) {
unordered_set<int> s;
fill(buc, buc + n + 1, 0);
FOR(i, 1, n) t[i] = input(), buc[t[i]]++; // DEBUG(i, t[i]);
int cnt1 = count_if(buc + 1, buc + n + 1, [&](auto a) { return a != 0; });
if (cnt1 <= n - 2) continue;
else if (cnt1 == n - 1) {
int m2 = 0, m0 = 0;
FOR(i, 1, n) {
if (buc[i] == 2) m2 = i;
if (buc[i] == 0) m0 = i;
}
// WARN(m2, m0);
FOR(i, 1, n) {
if (t[i] == m2) {
elist[id].push_back({i, m0});
}
}
} else {
FOR(i, 1, n) elist[id].push_back({i, t[i]});
}
}
FOR(i, 1, q) {
int a = input(), b = input(), c = input();
// INFO(a, b, c);
qlist[c].push_back({a, b, i});
}
FOR(i, 1, n) {
G[i].set(i);
}
FOR(i, 0, l) {
for (auto [u, v] : elist[i]) {
add(u, v);
}
for (auto [a, b, id] : qlist[i]) {
ans[id] = G[a].test(b);
}
}
FOR(i, 1, q) {
cout << ans[i];
}
cout << endl;
for (int i = 0; i <= n; i++) {
G[i].reset();
inq[i].reset();
}
for (int i = 0; i <= l; i++) {
elist[i].clear();
qlist[i].clear();
}
}
int main() {
ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
int t = 1;
cin >> t;
while (t--) solve();
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3528kb
input:
2 5 2 4 0305040201 0404040404 030300 020500 050102 020501 6 2 4 030603010601 010203060504 030202 060402 050602 060401
output:
1011 0100
result:
ok 2 lines
Test #2:
score: 0
Accepted
time: 0ms
memory: 3640kb
input:
1 3 3 6 020202 030301 030201 020102 030203 010201 010303 020303 010202
output:
010101
result:
ok single line: '010101'
Test #3:
score: -100
Wrong Answer
time: 71ms
memory: 6044kb
input:
200 10 10 5000 01060:04020305080709 0103070:060204050908 09070503080401060:02 050308010204090:0607 03010502040607080:09 03080109020504060:07 06050:09040302080107 07080305010409060:02 030809010:0204060507 0:060908070201050304 060700 090:03 09080: 070405 010703 0:0100 080601 030600 070206 0:0:09 08040...
output:
011110001101101111111111111111100101011110110101010110110110101011010101111111111111110101111111111110001111110111110111111101011111111110011111111111111111110001100111011111111111111111111011101110111111111111111111011111111111111111011011010100111110111111100111011100111111001110111111011001111110...
result:
wrong answer 1st lines differ - expected: '011110001101101111111111111111...1111111111111111101111111111111', found: '011110001101101111111111111111...1111111111111100100011111111011'