CSES - Datatähti 2024 loppu - Results
Submission details
Task:Peli
Sender:qanpi
Submission time:2024-01-20 14:13:38 +0200
Language:C++11
Status:READY
Result:0
Feedback
groupverdictscore
#10
#20
Test results
testverdicttimegroup
#10.00 s1, 2details
#20.00 s1, 2details
#30.45 s2details
#40.00 s1, 2details
#50.00 s1, 2details
#60.45 s2details
#70.45 s2details
#80.00 s1, 2details
#90.01 s2details
#100.46 s2details

Compiler report

input/code.cpp: In function 'bool search(int, int, int)':
input/code.cpp:19:1: warning: control reaches end of non-void function [-Wreturn-type]
   19 | }
      | ^

Code

#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;

vector<int> adj[2510];
//int distances[2510][2510];

bool search(int a, int b, int x) {
    if (a == b && x == 0) return true;
    if (x < 0) return false;

    bool flag = false;
    for (int u : adj[a]) {
        flag = search(u, b, x-1);
        if (flag) return true;
    }
}

int main() {
    int n, m, q;
    cin >> n >> m >> q;

    for (int i=0; i<m; i++) {
        int a, b;
        cin >> a >> b;

        adj[a].push_back(b);
        adj[b].push_back(a);
    }

    for (int i=0; i<q; i++) {
        int a, b, x;
        cin >> a >> b >> x;

        bool ans = search(a, b, x);
        if (ans) {
            cout << "YES" << endl;
        } else {
            cout << "NO" << endl;
        }
    }
}

Test details

Test 1

Group: 1, 2

Verdict:

input
2 1 100
1 2
1 1 0
1 2 0
2 1 0
...

correct output
YES
NO
NO
YES
NO
...

user output
YES

Test 2

Group: 1, 2

Verdict:

input
50 49 100
33 34
7 8
49 50
47 48
...

correct output
NO
NO
NO
NO
NO
...

user output
(empty)

Test 3

Group: 2

Verdict:

input
2500 2499 100000
821 822
2351 2352
752 753
832 833
...

correct output
NO
YES
YES
NO
NO
...

user output
(empty)

Test 4

Group: 1, 2

Verdict:

input
12 12 100
9 10
2 3
1 12
1 2
...

correct output
NO
NO
NO
NO
NO
...

user output
(empty)

Test 5

Group: 1, 2

Verdict:

input
11 11 100
10 11
7 8
1 2
5 6
...

correct output
YES
YES
YES
YES
YES
...

user output
(empty)

Test 6

Group: 2

Verdict:

input
2500 2500 100000
1936 1937
1884 1885
751 752
831 832
...

correct output
NO
YES
YES
NO
NO
...

user output
(empty)

Test 7

Group: 2

Verdict:

input
2499 2499 100000
821 822
2351 2352
752 753
832 833
...

correct output
YES
YES
YES
YES
YES
...

user output
(empty)

Test 8

Group: 1, 2

Verdict:

input
50 99 100
40 47
34 50
44 47
15 16
...

correct output
YES
YES
YES
YES
YES
...

user output
(empty)

Test 9

Group: 2

Verdict:

input
2500 4999 100000
1191 2361
251 399
1026 2300
82 1655
...

correct output
YES
YES
YES
YES
YES
...

user output
(empty)

Test 10

Group: 2

Verdict:

input
2500 4999 100000
2023 2218
23 51
1020 1272
11 114
...

correct output
YES
YES
YES
YES
YES
...

user output
(empty)