QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#629367 | #9319. Bull Farm | Andyqian7 | WA | 62ms | 4416kb | C++14 | 2.3kb | 2024-10-11 10:58:52 | 2024-10-11 10:58:52 |
Judging History
answer
#include <bits/stdc++.h>
#define rep(i, s, e) for (int i = s; i <= e; i++)
using namespace std;
const int N = 1024;
int n, l, q, t[N][N];
struct node
{
int a, b, no, ans;
friend bool operator<(node x, node y)
{
return x.no < y.no;
}
};
void qr(int &x)
{
x = (getchar() - 48) * 50 + getchar() - 48;
}
int main()
{
int T;
scanf("%d", &T);
while (T--)
{
scanf("%d%d%d\n", &n, &l, &q);
rep(i, 1, l)
{
rep(j, 1, n)
{
qr(t[i][j]);
}
getchar();
}
bitset<N> b[N];
rep(i, 1, n)
{
b[i][i] = 1;
}
vector<node> v[N];
rep(i, 1, q)
{
int a, b, c;
qr(a), qr(b), qr(c), getchar();
v[c].push_back({a, b, i});
}
for (auto &[a, B, _, ans] : v[0])
{
ans = b[a][B];
}
rep(i, 1, l)
{
int cnt[N] = {};
rep(j, 1, n)
cnt[t[i][j]]++;
int c = 0, emp;
rep(j, 1, n) if (cnt[j] > 1) c += cnt[j] - 1;
if (c <= 1)
{
if (!c)
{
rep(j, 1, n)
{
emp = t[i][j];
b[j] |= b[emp];
}
}
else
{
vector<int> C;
rep(j, 1, n)
{
if (!cnt[j])
emp = j;
if (cnt[t[i][j]] == 2)
C.push_back(j);
}
for (auto c : C)
b[c] |= b[emp];
}
}
for (auto &[a, B, _, ans] : v[i])
{
ans = b[a][B];
}
}
vector<node> all;
rep(i, 0, l)
{
for (auto j : v[i])
all.push_back(j);
}
sort(all.begin(), all.end());
for (auto i : all)
{
putchar(i.ans + 48);
}
puts("");
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3864kb
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: 4136kb
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: 62ms
memory: 4416kb
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:
011110001101101111111111111111100101111110010101010100110110101011010001011111011111110101111101111110111101110111111111111101011111111110011111111101111111110001100111011111111111111111111011001111111101111111111111111111111111111111011011010100111110111011110111011100101111101110111111111001110110...
result:
wrong answer 1st lines differ - expected: '011110001101101111111111111111...1111111111111111101111111111111', found: '011110001101101111111111111111...1111111111111110100111111111011'