# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1108300 |
2024-11-03T17:20:49 Z |
overwatch9 |
Paths (BOI18_paths) |
C++17 |
|
3000 ms |
15188 KB |
#include <bits/stdc++.h>
using namespace std;
int n, m, k;
const int maxn = 3e5+1;
vector <int> adj[maxn];
int col[maxn];
int cnt;
bool vis[maxn];
void solve(int s, int p, int x, int len, int has) {
if (vis[s] || len > k)
return;
vis[s] = true;
if (len > 1)
cnt++;
for (auto i : adj[s]) {
if (i == p)
continue;
if (has & (1 << col[i]))
continue;
solve(i, s, x + (1 << len) * col[i], len + 1, has + (1 << col[i]));
}
vis[s] = false;
}
int main() {
cin >> n >> m >> k;
for (int i = 1; i <= n; i++)
cin >> col[i];
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 = 1; i <= n; i++)
solve(i, i, col[i], 1, (1 << col[i]));
cout << cnt << '\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
8784 KB |
Output is correct |
2 |
Correct |
2 ms |
8784 KB |
Output is correct |
3 |
Correct |
2 ms |
8784 KB |
Output is correct |
4 |
Correct |
3 ms |
8528 KB |
Output is correct |
5 |
Correct |
3 ms |
8784 KB |
Output is correct |
6 |
Correct |
2 ms |
8784 KB |
Output is correct |
7 |
Correct |
2 ms |
8952 KB |
Output is correct |
8 |
Correct |
2 ms |
8784 KB |
Output is correct |
9 |
Correct |
2 ms |
8528 KB |
Output is correct |
10 |
Correct |
2 ms |
8784 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2369 ms |
15188 KB |
Output is correct |
2 |
Execution timed out |
3060 ms |
14404 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
8784 KB |
Output is correct |
2 |
Correct |
2 ms |
8784 KB |
Output is correct |
3 |
Correct |
2 ms |
8784 KB |
Output is correct |
4 |
Correct |
3 ms |
8528 KB |
Output is correct |
5 |
Correct |
3 ms |
8784 KB |
Output is correct |
6 |
Correct |
2 ms |
8784 KB |
Output is correct |
7 |
Correct |
2 ms |
8952 KB |
Output is correct |
8 |
Correct |
2 ms |
8784 KB |
Output is correct |
9 |
Correct |
2 ms |
8528 KB |
Output is correct |
10 |
Correct |
2 ms |
8784 KB |
Output is correct |
11 |
Correct |
2369 ms |
15188 KB |
Output is correct |
12 |
Execution timed out |
3060 ms |
14404 KB |
Time limit exceeded |
13 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
8528 KB |
Output is correct |
2 |
Execution timed out |
3067 ms |
10580 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |