# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
852390 | 2023-09-21T18:04:08 Z | Benmath | Paths (BOI18_paths) | C++14 | 1450 ms | 529496 KB |
/****************************************************************************** Online C++ Compiler. Code, Compile, Run and Debug C++ program online. Write your code in this editor and press "Run" button to compile and execute it. *******************************************************************************/ #include <bits/stdc++.h> using namespace std; long long int dp[300005][6][6][6]; int boja[300005]; int n; int m; int k; vector<int>adjl[300005]; int main() { cin >> n >> m >> k; for (int i = 1; i <= n; i++){ cin >> boja[i]; } for (int i = 0; i < m; i++){ int x, y; cin >> x >> y; adjl[x].push_back(y); adjl[y].push_back(x); } long long int ans = 0; for (int i = k; i >= 0; i--){ for (int j = k; j >= 0; j--){ for (int t = k; t >= 0; t--){ for (int node = 1; node <= n; node++){ if (i == 0){ if (j == 0 and t == 0){ for (int susjed = 0; susjed < adjl[node].size(); susjed ++){ int x = boja[adjl[node][susjed]]; if(x != boja[node] and x != i and x != j and x != t){ dp[node][i][j][t] += dp[adjl[node][susjed]][boja[node]][0][0]; } } } }else{ if (j == 0){ if (t == 0){ for (int susjed = 0; susjed < adjl[node].size(); susjed ++){ int x = boja[adjl[node][susjed]]; if(x != boja[node] and x != i and x != j and x != t){ dp[node][i][j][t] += dp[adjl[node][susjed]][i][boja[node]][0]; } } } }else{ if (t == 0){ for (int susjed = 0; susjed < adjl[node].size(); susjed ++){ int x = boja[adjl[node][susjed]]; if(x != boja[node] and x != i and x != j and x != t){ dp[node][i][j][t] += dp[adjl[node][susjed]][i][j][boja[node]]; } } }else{ } } } int check = 0; if (i == j and i > 0){ check ++; } if (j == t and j > 0){ check ++; } if (i == t and i > 0){ check ++; } if(boja[node] != i and boja[node] != j and boja[node] != t and check == 0){ dp[node][i][j][t] += 1; } if(i == 0 and j == 0 and t == 0){ ans = ans + dp[node][i][j][t]; ans --; } //cout << dp[node][i][j][t]<<" "<<i<<" "<<j<<" "<<t<<" "<<node<<" "<<boja[node]<<endl; } } } } cout << ans << endl; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 8792 KB | Output is correct |
2 | Correct | 3 ms | 8792 KB | Output is correct |
3 | Correct | 2 ms | 8796 KB | Output is correct |
4 | Correct | 2 ms | 8796 KB | Output is correct |
5 | Correct | 2 ms | 8792 KB | Output is correct |
6 | Correct | 2 ms | 8792 KB | Output is correct |
7 | Correct | 2 ms | 8792 KB | Output is correct |
8 | Correct | 2 ms | 8796 KB | Output is correct |
9 | Correct | 2 ms | 8792 KB | Output is correct |
10 | Correct | 2 ms | 8796 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 175 ms | 20560 KB | Output is correct |
2 | Correct | 142 ms | 13396 KB | Output is correct |
3 | Correct | 905 ms | 527876 KB | Output is correct |
4 | Correct | 207 ms | 67152 KB | Output is correct |
5 | Correct | 154 ms | 67664 KB | Output is correct |
6 | Correct | 666 ms | 357972 KB | Output is correct |
7 | Correct | 923 ms | 528728 KB | Output is correct |
8 | Correct | 897 ms | 529232 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 8792 KB | Output is correct |
2 | Correct | 3 ms | 8792 KB | Output is correct |
3 | Correct | 2 ms | 8796 KB | Output is correct |
4 | Correct | 2 ms | 8796 KB | Output is correct |
5 | Correct | 2 ms | 8792 KB | Output is correct |
6 | Correct | 2 ms | 8792 KB | Output is correct |
7 | Correct | 2 ms | 8792 KB | Output is correct |
8 | Correct | 2 ms | 8796 KB | Output is correct |
9 | Correct | 2 ms | 8792 KB | Output is correct |
10 | Correct | 2 ms | 8796 KB | Output is correct |
11 | Correct | 175 ms | 20560 KB | Output is correct |
12 | Correct | 142 ms | 13396 KB | Output is correct |
13 | Correct | 905 ms | 527876 KB | Output is correct |
14 | Correct | 207 ms | 67152 KB | Output is correct |
15 | Correct | 154 ms | 67664 KB | Output is correct |
16 | Correct | 666 ms | 357972 KB | Output is correct |
17 | Correct | 923 ms | 528728 KB | Output is correct |
18 | Correct | 897 ms | 529232 KB | Output is correct |
19 | Correct | 207 ms | 23376 KB | Output is correct |
20 | Correct | 145 ms | 15840 KB | Output is correct |
21 | Correct | 898 ms | 528744 KB | Output is correct |
22 | Correct | 210 ms | 67132 KB | Output is correct |
23 | Correct | 159 ms | 67676 KB | Output is correct |
24 | Correct | 650 ms | 358268 KB | Output is correct |
25 | Correct | 906 ms | 528668 KB | Output is correct |
26 | Correct | 911 ms | 529496 KB | Output is correct |
27 | Correct | 172 ms | 15696 KB | Output is correct |
28 | Correct | 218 ms | 29264 KB | Output is correct |
29 | Correct | 1450 ms | 528732 KB | Output is correct |
30 | Correct | 806 ms | 272196 KB | Output is correct |
31 | Correct | 765 ms | 272144 KB | Output is correct |
32 | Correct | 1391 ms | 528740 KB | Output is correct |
33 | Correct | 2 ms | 8792 KB | Output is correct |
34 | Correct | 2 ms | 8796 KB | Output is correct |
35 | Correct | 2 ms | 8796 KB | Output is correct |
36 | Correct | 2 ms | 8792 KB | Output is correct |
37 | Correct | 2 ms | 8796 KB | Output is correct |
38 | Correct | 2 ms | 8792 KB | Output is correct |
39 | Correct | 2 ms | 8792 KB | Output is correct |
40 | Correct | 2 ms | 8792 KB | Output is correct |
41 | Correct | 2 ms | 8792 KB | Output is correct |
42 | Correct | 2 ms | 8792 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 8792 KB | Output is correct |
2 | Incorrect | 71 ms | 10420 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |