QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#54627 | #4197. Natural Navigation | Username# | WA | 9ms | 15440kb | C++23 | 1.3kb | 2022-10-09 21:27:57 | 2022-10-09 21:28:00 |
Judging History
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;
}
Details
Tip: Click on the bar to expand more detailed information
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'