QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#577262 | #9319. Bull Farm | ewe | WA | 245ms | 9920kb | C++14 | 2.9kb | 2024-09-20 09:49:29 | 2024-09-20 09:49:29 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define fopen \
freopen("in.txt", "r", stdin); \
freopen("out.txt", "w", stdout);
#define ls(x) (x << 1)
#define rs(x) (x << 1 | 1)
#define lowbit(x) (x & -x)
#define i64 long long
#define pii pair<int, int>
#define de(x) cout << #x << " = " << x << '\n'
const int N = 2e3 + 10, M = 1e6 + 10, mod = 1e9 + 7;
const double eps = 1e-6;
int t[N][N], dp[N][N];
array<int, 4> qu[M];
int ans[M];
vector<int> vec[N];
int n, m, q;
void add(int k)
{
vector<int> vis(n + 1, 0);
int same = 0, left = 0;
for (int i = 1, x; i <= n; i++)
{
x = t[k][i];
if (vis[x])
{
if (!same)
same = x;
else
return;
}
vis[x] = 1;
}
if (!same)
{
for (int i = 1; i <= n; i++)
if (t[k][i] != i)
{
int y = t[k][i];
for (int x : vec[i])
{
if (!dp[x][y])
vec[y].push_back(x);
dp[x][y] = 1;
}
for (int j = 1; j <= n; j++)
if (dp[y][j])
{
if (!dp[i][j])
vec[j].push_back(i);
dp[i][j] = 1;
}
}
return;
}
for (int i = 1; i <= n; i++)
if (!vis[i])
left = i;
for (int i = 1; i <= n; i++)
if (t[k][i] == same)
{
for (int x : vec[i])
{
if (!dp[x][left])
vec[left].push_back(x);
dp[x][left] = 1;
}
}
}
void solve()
{
cin >> n >> m >> q;
for (int i = 1; i <= n; i++)
{
for (int j = 1; j <= n; j++)
dp[i][j] = i == j;
vec[i].resize(1, i);
}
for (int i = 1; i <= m; i++)
{
string s;
cin >> s;
for (int j = 1, x; j <= n; j++)
{
x = (s[j + j - 2] - 48) * 50 + (s[j + j - 1] - 48);
t[i][j] = x;
}
}
for (int i = 1, a, b, c; i <= q; i++)
{
string s;
cin >> s;
a = (s[0] - 48) * 50 + s[1] - 48;
b = (s[2] - 48) * 50 + s[3] - 48;
c = (s[4] - 48) * 50 + s[5] - 48;
qu[i] = {c, a, b, i};
}
sort(qu + 1, qu + q + 1);
for (int i = 1, k = 1; i <= q; i++)
{
auto [c, a, b, id] = qu[i];
while (k <= c)
{
add(k);
++k;
}
ans[id] = dp[a][b];
}
for (int i = 1; i <= q; i++)
cout << ans[i];
cout << '\n';
}
signed main()
{
// fopen;
int t = 1;
cin >> t;
while (t--)
solve();
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 9776kb
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: 1ms
memory: 9920kb
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: 245ms
memory: 9724kb
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:
011110001101101111111111111111111101111110110111011110110110111011010111011111111111111101111101111110111111110111111111111101011111111110111111111111111111110001100111011111111111111111111011101111111101111111111111111111111111111111011011110100111110111111110111011100111111101110111111111001111110...
result:
wrong answer 1st lines differ - expected: '011110001101101111111111111111...1111111111111111101111111111111', found: '011110001101101111111111111111...1111111111111111100111111111011'