QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#54627#4197. Natural NavigationUsername#WA 9ms15440kbC++231.3kb2022-10-09 21:27:572022-10-09 21:28:00

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-10-09 21:28:00]
  • 评测
  • 测评结果:WA
  • 用时:9ms
  • 内存:15440kb
  • [2022-10-09 21:27:57]
  • 提交

answer

#include <bits/stdc++.h>

#define el '\n'
#define ll long long
#define ld long double

#define Beevo ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

using namespace std;

const ll INF = 1e18;
const int N = 5e5 + 5;

struct Edge {
    int v;
    int c;
    vector<int> colors;
};

int n;
ll dp[N];
int vis[N];
vector<Edge> g[N];

ll dfs(int u) {
    if (u == n)
        return 0;

    if (vis[u] == 2)
        return INF;

    if (vis[u] == 1)
        return dp[u];

    vis[u] = 2;

    map<int, ll> mxColor;

    for (auto v: g[u]) {
        for (auto col: v.colors)
            mxColor[col] = max(mxColor[col], dfs(v.v) + v.c);
    }

    dp[u] = INF;

    for (auto i: mxColor)
        dp[u] = min(dp[u], i.second);

    vis[u] = 1;

    return dp[u];
}

void testCase() {
    int m, k;
    cin >> n >> m >> k;

    int u, v, t, s;
    while (m--) {
        cin >> u >> v >> t >> s;

        vector<int> colors(s);
        for (auto &i: colors)
            cin >> i;

        g[u].push_back({v, t, colors});
    }

    auto sol = dfs(1);

    if (sol == INF)
        cout << "impossible";
    else
        cout << sol;
}

signed main() {
    Beevo

    int T = 1;
//    cin >> T;

    while (T--)
        testCase();

    return 0;
}

详细

Test #1:

score: 100
Accepted
time: 3ms
memory: 15436kb

input:

4 6 2
1 2 6
1 1
1 3 3
1 2
2 3 5
1 2
2 4 8
1 1
3 1 4
2 1 2
3 4 3
1 1

output:

14

result:

ok single line: '14'

Test #2:

score: 0
Accepted
time: 2ms
memory: 15224kb

input:

3 4 3
1 2 300
2 1 2
2 1 2000
2 3 1
1 3 80
2 2 1
2 2 42
1 2

output:

impossible

result:

ok single line: 'impossible'

Test #3:

score: 0
Accepted
time: 4ms
memory: 15344kb

input:

3 2 3
1 2 1
3 1 2 3
1 3 1
2 1 2

output:

impossible

result:

ok single line: 'impossible'

Test #4:

score: 0
Accepted
time: 4ms
memory: 15440kb

input:

4 5 1
1 4 1
1 1
4 3 1
1 1
3 2 1
1 1
2 1 1
1 1
1 3 1
1 1

output:

impossible

result:

ok single line: 'impossible'

Test #5:

score: 0
Accepted
time: 9ms
memory: 15284kb

input:

2 2 3
1 2 3
3 1 2 3
1 2 4
3 1 2 3

output:

4

result:

ok single line: '4'

Test #6:

score: 0
Accepted
time: 2ms
memory: 15272kb

input:

10 12 3
4 4 5
1 1
1 7 5
1 1
1 2 5
1 1
8 4 2
1 1
8 10 5
1 1
6 8 2
1 2
6 5 1
1 2
6 10 7
1 3
5 5 8
1 2
7 1 5
1 1
2 1 6
1 1
2 8 1
1 1

output:

impossible

result:

ok single line: 'impossible'

Test #7:

score: 0
Accepted
time: 0ms
memory: 15280kb

input:

10 19 3
2 2 5
1 2
2 9 4
1 1
2 10 7
1 3
2 4 4
1 3
3 1 9
1 3
5 3 3
1 1
9 3 5
1 2
9 5 10
1 1
9 9 8
1 1
9 6 3
1 3
8 3 6
2 1 3
10 8 8
1 3
10 1 4
1 1
1 9 5
1 1
4 2 2
1 3
4 3 3
1 1
6 9 4
1 2
6 8 4
1 2
6 4 8
1 3

output:

impossible

result:

ok single line: 'impossible'

Test #8:

score: -100
Wrong Answer
time: 5ms
memory: 15380kb

input:

10 40 3
4 4 3
2 2 3
4 6 1
1 3
4 10 4
1 2
4 2 4
1 2
4 7 5
2 1 3
6 8 2
2 1 2
6 10 7
1 3
6 2 5
2 2 3
8 10 7
1 3
8 1 10
1 2
9 8 1
1 1
9 10 7
1 1
9 2 10
2 2 3
9 5 9
1 1
10 4 1
1 3
10 6 5
1 1
10 9 10
1 1
10 2 5
1 2
10 1 4
1 2
10 7 9
1 1
2 6 6
1 2
2 8 3
1 3
2 9 8
1 2
2 2 4
2 1 2
2 5 8
1 2
2 7 3
1 1
5 2 1
1...

output:

impossible

result:

wrong answer 1st lines differ - expected: '39', found: 'impossible'