QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#873921#9677. 基础博弈练习题A_programmer0 51ms44768kbC++171.1kb2025-01-27 09:07:092025-01-27 09:07:09

Judging History

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

  • [2025-01-27 09:07:09]
  • 评测
  • 测评结果:0
  • 用时:51ms
  • 内存:44768kb
  • [2025-01-27 09:07:09]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
const int maxn = 1e6 + 5;
const int inf = 0x3f3f3f3f;

int a[maxn], b[maxn], q[maxn], in[maxn], ans[maxn], n;
vector<int> g[maxn];

void Topo()
{
    int hd = 1, tl = 0;
    for (int i = 1; i <= n; i++) if (!in[i]) q[++tl] = i;
    while (hd <= tl)
    {
        int u = q[hd++];
        for (int v : g[u])
            if (--in[v] == 0) q[++tl] = v;
    }
}

int main()
{
    ios::sync_with_stdio(false), cin.tie(0);

    int m, k; cin >> n >> m >> k;
    for (int i = 1; i <= n; i++) cin >> a[i];
    for (int i = 1; i <= k; i++) cin >> b[i];
    for (int i = 1; i <= m; i++)
    {
        int u, v; cin >> u >> v;
        g[u].emplace_back(v), in[v]++;
    }
    Topo();
    for (int i = n; i; i--)
    {
        int u = q[i]; ans[u] = inf;
        for (int v : g[u])
        {
            ans[u] = min(ans[u], ans[v]);
            if (a[v] <= k && ans[v] > a[v] + 1) ans[u] = min(ans[u], a[v] - 1);
        }
    }
    for (int i = 1; i <= n; i++) cout << (ans[i] == inf ? -1 : ans[i]) << " ";
    return 0;
}

詳細信息

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 37144kb

input:

83 93 13
8 9 10 7 7 7 6 3 1 10 6 2 5 7 1 3 4 2 1 10 7 4 8 9 2 2 1 9 2 5 1 7 8 6 1 9 9 10 4 1 2 9 2 3 4 2 9 10 8 1 4 1 8 4 1 4 4 7 4 8 2 9 2 5 2 2 3 3 8 5 2 9 3 10 8 8 1 6 6 1 6 7 10
7 5 10 3 2 2 7 4 8 7 6 6 5
56 36
33 41
32 62
37 7
6 53
41 13
9 36
44 77
38 62
76 16
72 5
40 13
55 60
5 78
72 45
13 44
...

output:

0 -1 -1 0 0 0 0 3 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 -1 0 -1 0 0 -1 -1 0 0 0 0 -1 0 0 0 0 0 0 0 0 -1 0 -1 -1 0 0 0 -1 0 0 0 0 0 0 -1 -1 0 0 0 0 0 0 0 0 -1 0 0 -1 0 0 1 1 0 0 0 2 0 0 0 0 0 

result:

wrong answer 4th numbers differ - expected: '-1', found: '0'

Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Wrong Answer

Test #6:

score: 0
Wrong Answer
time: 51ms
memory: 44768kb

input:

100000 355071 10000
5 7 4 7 4 1 10 5 9 4 9 4 3 10 5 4 9 1 7 10 1 6 10 3 10 9 8 4 6 3 10 8 6 8 3 5 10 9 7 7 1 3 8 8 6 2 8 4 2 9 1 10 3 6 3 8 9 10 5 7 3 2 1 5 7 4 3 4 6 4 2 7 2 5 5 6 4 6 7 4 4 6 4 2 3 9 9 9 10 8 1 6 7 2 9 8 2 3 1 6 9 4 10 3 10 1 2 3 3 4 1 1 1 5 8 6 8 3 1 6 2 9 5 9 4 7 2 10 7 5 2 2 7 4...

output:

0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

result:

wrong answer 911th numbers differ - expected: '7', found: '9'

Subtask #4:

score: 0
Skipped

Dependency #3:

0%

Subtask #5:

score: 0
Skipped

Dependency #4:

0%