QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#543813 | #8517. Interesting Paths | HTensor# | WA | 1ms | 6168kb | C++17 | 1.1kb | 2024-09-01 20:37:48 | 2024-09-01 20:37:49 |
Judging History
answer
#include <bits/stdc++.h>
#define dd(x) cout << #x << "\n"
#define d(x) cout << #x << ": " << x << "\n"
using namespace std;
#define int long long
using pii = pair<int, int>;
using vpii = vector<pii>;
using vi = vector<int>;
using vii = vector<vector<int>>;
using a3 = array<int, 3>;
const int inf = 0x3f3f3f3f3f3f3f3fLL;
const int N = 1e5 + 5;
vector<int> adj[N];
void solve() {
int n, m; cin >> n >> m;
vector<int> rd(n + 1), vis(n + 1), dp(n + 1);
for(int i = 1; i <= m; i++) {
int u, v; cin >> u >> v;
adj[v].push_back(u);
rd[u]++;
}
queue<int> Q; Q.push(n);
dp[n] = 0;
while(!Q.empty()) {
int u = Q.front(); Q.pop();
for(auto v : adj[u]) {
// if(vis[v]) continue;
dp[v] = max(dp[v], dp[u] + 1);
Q.push(v);
}
}
cout << dp[1] << "\n";
}
signed main() {
ios::sync_with_stdio(false); cin.tie(0);
int T = 1;
while(T--) solve();
return 0;
}
/*
5 7
1 3
3 5
1 2
2 3
3 4
4 5
2 4
*/
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 6140kb
input:
5 7 1 3 3 5 1 2 2 3 3 4 4 5 2 4
output:
4
result:
ok 1 number(s): "4"
Test #2:
score: 0
Accepted
time: 1ms
memory: 5836kb
input:
5 3 1 3 2 3 2 5
output:
0
result:
ok 1 number(s): "0"
Test #3:
score: 0
Accepted
time: 1ms
memory: 6168kb
input:
2 0
output:
0
result:
ok 1 number(s): "0"
Test #4:
score: 0
Accepted
time: 0ms
memory: 5916kb
input:
2 1 1 2
output:
1
result:
ok 1 number(s): "1"
Test #5:
score: 0
Accepted
time: 1ms
memory: 5968kb
input:
10 20 2 8 5 8 4 8 3 10 3 7 2 7 2 5 1 7 6 9 6 10 2 4 5 9 2 10 3 9 7 8 4 10 3 6 2 3 5 7 6 8
output:
0
result:
ok 1 number(s): "0"
Test #6:
score: -100
Wrong Answer
time: 1ms
memory: 5904kb
input:
10 30 8 9 1 5 3 6 4 6 4 7 6 9 3 5 5 6 3 8 1 4 3 4 7 8 2 4 4 5 1 8 6 10 2 10 9 10 1 2 8 10 2 7 2 8 2 5 7 9 2 6 4 8 1 7 1 6 7 10 4 9
output:
6
result:
wrong answer 1st numbers differ - expected: '19', found: '6'