QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#466663#8517. Interesting PathsEl_7la2een#WA 0ms3852kbC++20663b2024-07-08 00:55:522024-07-08 00:55:52

Judging History

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

  • [2024-07-08 00:55:52]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3852kb
  • [2024-07-08 00:55:52]
  • 提交

answer


#include<bits/stdc++.h>
using namespace std;
int n;
int dfs(vector<vector<int>>& v, vector<int>& dp, int node) {
    if (node == n)return 1;

    if (dp[node] != -1)return 1;
    
    auto& ret = dp[node];
    ret = 0;

    for (auto& to : v[node]) {
        ret += dfs(v, dp, to);
    }

    return ret;
}

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

    cin >> n;
    int m;
    cin >> m;

    vector<vector<int>>v(n+1);
    vector<int>dp(n + 1,-1);
    while (m--) {
        int a, b;
        cin >> a >> b;
        v[a].push_back(b);

    }

    cout << dfs(v, dp, 1) << "\n";
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3656kb

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: 0ms
memory: 3792kb

input:

5 3
1 3
2 3
2 5

output:

0

result:

ok 1 number(s): "0"

Test #3:

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

input:

2 0

output:

0

result:

ok 1 number(s): "0"

Test #4:

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

input:

2 1
1 2

output:

1

result:

ok 1 number(s): "1"

Test #5:

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

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: 0
Accepted
time: 0ms
memory: 3544kb

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:

19

result:

ok 1 number(s): "19"

Test #7:

score: -100
Wrong Answer
time: 0ms
memory: 3852kb

input:

20 57
6 20
5 9
8 11
6 17
5 18
14 16
6 18
8 18
1 3
17 20
2 16
4 19
2 15
7 17
17 19
8 16
11 15
13 16
5 20
4 14
5 16
7 12
10 12
3 12
8 13
1 5
6 11
13 17
11 16
2 6
4 5
14 15
3 14
9 13
8 10
18 20
15 17
6 12
5 17
2 10
8 17
15 16
15 20
5 19
10 15
1 2
4 20
4 18
3 16
2 12
8 19
10 19
2 11
12 17
12 20
5 7
1 15

output:

29

result:

wrong answer 1st numbers differ - expected: '21', found: '29'