Submission details
Task:Polut
Sender:rottis
Submission time:2026-01-17 14:38:44 +0200
Language:C++ (C++17)
Status:READY
Result:9
Feedback
groupverdictscore
#1ACCEPTED9
#20
#30
#40
#50
Test results
testverdicttimegroup
#1ACCEPTED0.01 s1, 3, 4, 5details
#2ACCEPTED0.01 s1, 4, 5details
#3ACCEPTED0.07 s1, 4, 5details
#4ACCEPTED0.05 s1, 4, 5details
#50.09 s2, 5details
#60.09 s2, 5details
#7--2, 4, 5details
#80.09 s3, 5details
#90.09 s3, 5details
#10--3, 4, 5details
#11--4, 5details
#12--4, 5details
#130.10 s5details
#140.10 s5details
#15--4, 5details
#16ACCEPTED0.01 s1, 4, 5details

Code

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

const int M = 1e9 + 7;

int n, m, p, t;
vector<int> g[100001];
int dist_from_end[100001];

void find_shortest() {
    priority_queue<pair<int, int>> q;
    q.push({-1, n});
    bool vis[100001];

    while (!q.empty()) {
        pair<int, int> cur = q.top(); q.pop();

        if (vis[cur.second]) continue;
        vis[cur.second] = true;
        dist_from_end[cur.second] = -cur.first;

        for (int con : g[cur.second]) {
            q.push({cur.first - 1, con});
        }
    }
}

bool vis[100001]; // if extras == 1 and we go to an old node, return

ll dfs(int node, int steps_left) {
    if (steps_left == 0) return node == n;

    ll res = 0;
    vis[node] = true;
    for (int con : g[node]) {
        if (t <= 1 && vis[con]) continue;
        if (dist_from_end[con] > steps_left+1) continue;
        
        res += dfs(con, steps_left-1); res %= M;
    }
    vis[node] = false;
    return res;
}

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

    cin >> n >> m >> p;

    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    find_shortest();

    for (t = 0; t < p; t++) {
        cout << dfs(1, dist_from_end[1] + t-1) << ' ';
    }

    return 0;
}

Test details

Test 1 (public)

Group: 1, 3, 4, 5

Verdict: ACCEPTED

input
4 5 3
1 2
1 3
2 3
2 4
...

correct output
2 2 10 

user output
2 2 10 

Test 2

Group: 1, 4, 5

Verdict: ACCEPTED

input
2 1 1
2 1

correct output

user output

Test 3

Group: 1, 4, 5

Verdict: ACCEPTED

input
10 20 10
6 10
8 1
4 6
9 1
...

correct output
2 5 34 123 611 2503 11415 4882...

user output
2 5 34 123 611 2503 11415 4882...

Test 4

Group: 1, 4, 5

Verdict: ACCEPTED

input
10 20 10
4 10
2 3
8 4
7 8
...

correct output
1 7 26 140 509 2483 9454 43570...

user output
1 7 26 140 509 2483 9454 43570...

Test 5

Group: 2, 5

Verdict:

input
100000 200000 2
96303 53915
64836 4748
6389 40954
60420 91374
...

correct output
1 0 

user output
0 0 

Feedback: Incorrect character on line 1 col 1: expected "1", got "0"

Test 6

Group: 2, 5

Verdict:

input
100000 200000 2
72817 17293
93269 856
51497 26888
41679 96276
...

correct output
5 8 

user output
0 0 

Feedback: Incorrect character on line 1 col 1: expected "5", got "0"

Test 7

Group: 2, 4, 5

Verdict:

input
474 517 2
1 2
1 3
2 4
3 4
...

correct output
0 0 

user output
(empty)

Test 8

Group: 3, 5

Verdict:

input
100000 200000 3
59846 53439
11468 57874
83443 13914
46177 15147
...

correct output
1 0 32 

user output
0 0 0 

Feedback: Incorrect character on line 1 col 1: expected "1", got "0"

Test 9

Group: 3, 5

Verdict:

input
100000 200000 3
23665 7205
83252 56604
14852 7299
2836 9864
...

correct output
1 0 33 

user output
0 0 0 

Feedback: Incorrect character on line 1 col 1: expected "1", got "0"

Test 10

Group: 3, 4, 5

Verdict:

input
474 517 3
1 2
1 3
2 4
3 4
...

correct output
0 0 986681410 

user output
(empty)

Test 11

Group: 4, 5

Verdict:

input
1000 2000 10
691 424
80 318
681 539
33 342
...

correct output
1 6 39 252 1242 7715 36269 212...

user output
(empty)

Test 12

Group: 4, 5

Verdict:

input
1000 2000 10
979 324
770 562
560 7
169 738
...

correct output
2 2 81 150 2435 6460 66843 223...

user output
(empty)

Test 13

Group: 5

Verdict:

input
100000 200000 10
54544 86042
14060 20746
47891 4317
76648 84193
...

correct output
1 3 54 169 1917 6237 56922 192...

user output
0 0 0 0 0 0 0 0 0 1 

Feedback: Incorrect character on line 1 col 1: expected "1", got "0"

Test 14

Group: 5

Verdict:

input
100000 200000 10
73275 88704
74521 54506
51906 57193
29561 44568
...

correct output
6 19 338 1212 12462 49357 3873...

user output
0 0 0 0 0 0 0 0 0 0 

Feedback: Incorrect character on line 1 col 1: expected "6", got "0"

Test 15

Group: 4, 5

Verdict:

input
1000 1989 10
822 821
979 989
138 139
968 981
...

correct output
1 44 2935 131120 6357888 28564...

user output
(empty)

Test 16

Group: 1, 4, 5

Verdict: ACCEPTED

input
3 3 1
1 2
1 3
2 3

correct output

user output