CSES - Datatähti 2024 loppu - Results
Submission details
Task:Peli
Sender:stpn129
Submission time:2024-01-20 15:48:41 +0200
Language:C++ (C++17)
Status:READY
Result:0
Feedback
groupverdictscore
#10
#20
Test results
testverdicttimegroup
#10.00 s1, 2details
#20.00 s1, 2details
#3--2details
#40.00 s1, 2details
#50.00 s1, 2details
#6--2details
#7--2details
#80.00 s1, 2details
#9--2details
#10--2details

Code

#include<bits/stdc++.h>
using namespace std;
 
void init_code(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif 
}

const int inf = 1e9 + 7;
void solve() {
   int n, m, q;
   cin >> n >> m >> q;

   vector<vector<int>> g(n + 1, vector<int> (n + 1, inf));
   for (int i = 1; i <= m; ++i) {
      int a, b;
      cin >> a >> b;
      g[a][b] = 1;
      g[b][a] = 1;
   }

   for (int i = 1; i <= n; ++i) {
      g[i][i] = 0;
   }
   
   vector<vector<int>> dist(n + 1, vector<int> (n + 1, inf));
   dist = g;

   for (int k = 1; k <= n; ++k) {
      for (int i = 1; i <= n; ++i) {
         for (int j = 1; j <= n; ++j) {
            dist[i][j] = min(dist[i][j], dist[i][k] + g[k][j]);
         }
      }
   }

   for (int i = 1; i <= n; ++i) {
      for (int j = 1; j <= n; ++j) {
         cout << dist[i][j] << ' ';
      }
      cout << '\n';
   }

   for (int i = 1; i <= q; ++i) {
      int a, b, x;
      cin >> a >> b >> x;
      int check = (dist[a][b] <= x) && ((x - dist[a][b]) % 2 == 0);
      for (int i = 1; i <= n; ++i) {
         if (((g[a][i] + g[i][b]) <= x) && ((x - g[i][b]) % 2 == 0)) check = 1;
         if (check) 
            break;
      }
      if (check) cout << "YES" << '\n';
      else cout << "NO" << '\n';
   }
}
 
int main() {
   init_code();
   solve();
   return 0;
}

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
0 1 
1 0 
YES
NO
NO
...
Truncated

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
0 1 2 3 4 5 6 7 8 9 10 11 12 1...
Truncated

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
0 1 2 3 4 5 6 7 8 9 2 1 
1 0 1 2 3 4 5 6 7 8 3 2 
2 1 0 1 2 3 4 5 6 7 8 9 
9 2 1 0 1 2 3 4

...
Truncated

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
0 1 2 3 4 5 6 7 8 2 1 
1 0 1 2 3 4 5 6 7 3 2 
2 1 0 1 2 3 4 5 6 7 8 
8 2 1 0 1 2 3 4 5 6 7

...
Truncated

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
0 1 2 1 1 2 2 2 1 3 3 3 3 2 2 ...
Truncated

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)