QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#567789 | #9319. Bull Farm | lmx111 | RE | 0ms | 0kb | C++20 | 2.4kb | 2024-09-16 13:55:51 | 2024-09-16 13:55:54 |
answer
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;
int z[2009][2009];
int cur[2009];
int du[2009];
bool w[2009][2009];
bool vis[2009];
vector<pair<int,int>>zzz[2009];
priority_queue<pair<int, int>> qqq;
void solve() {
int n, l, q;
cin >> n >> l >> q;
getchar();
for (int i = 1; i <= n; i++) {
zzz[i].clear();
for (int j = 1; j <= n; j++) {
z[i][j] = 1000000000000000;
w[i][j] = 0;
}
}
for (int i = 1; i <= n; i++) {
w[i][i] = 1;
}
for (int i = 1; i <= l; i++) {
for (int i = 1; i <= n; i++) {
du[i] = 0;
cur[i] = 0;
}
for (int j = 1; j <= n; j++) {
for (int k = 1; k <= 2; k++) {
cur[j] *= 50;
char a = getchar();
cur[j] += a - '0';
}
}
getchar();
for (int k = 1; k <= n; k++) {
du[cur[k]]++;
}
int flag1 = 0, flag2 = 0;
for (int k = 1; k <= n; k++) {
if (du[k] != 1) {
flag1++;
}
if (du[k] == 0) {
flag2 = k;
}
}
if (flag1 == 0) {
for (int k = 1; k <= n; k++) {
if (w[k][cur[k]]) {
continue;
}
zzz[k].push_back({ -i, cur[k] });
w[k][cur[k]] = 1;
}
}
else {
if (flag1 == 2) {
for (int k = 1; k <= n; k++) {
if (du[cur[k]] == 2 && w[k][flag2] == 0) {
zzz[k].push_back({ -i, flag2 });
w[k][flag2] = 1;
}
}
}
}
}
for (int i = 1; i <= n; i++) {
for (int i = 1; i <= n; i++) {
vis[i] = 0;
}
qqq.push({ 0, i });
while (!qqq.empty()) {
pair<int, int> u = qqq.top();
qqq.pop();
if (vis[u.second] == 1)
continue;
z[i][u.second] = -u.first;
vis[u.second] = 1;
for (auto ed : zzz[u.second]) {
int www = ed.first, v = ed.second;
if (vis[v] == 1)
continue;
qqq.push({ -max(z[i][u.second],-www), v });
}
}
}
for (int i = 1; i <= q; i++) {
int u = 0;
for (int k = 1; k <= 2; k++) {
u *= 50;
char a = getchar();
u += a - '0';
}
int v = 0;
for (int k = 1; k <= 2; k++) {
v *= 50;
char a = getchar();
v += a - '0';
}
int w = 0;
for (int k = 1; k <= 2; k++) {
w *= 50;
char a = getchar();
w += a - '0';
}
getchar();
if (z[u][v] <= w) {
putchar('1');
}
else {
putchar('0');
}
}
putchar('\n');
}
signed main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int t = 1;
cin >> t;
while (t--) {
solve();
}
return 0;
}
詳細信息
Test #1:
score: 0
Runtime Error
input:
2 5 2 4 0305040201 0404040404 030300 020500 050102 020501 6 2 4 030603010601 010203060504 030202 060402 050602 060401