# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
863410 |
2023-10-20T07:37:20 Z |
maks007 |
Paths (BOI18_paths) |
C++14 |
|
3000 ms |
8104 KB |
// Bismi Allah
#include "bits/stdc++.h"
using namespace std;
#define int long long
signed main () {
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int n, m, k, ans = 0;
cin >> n >> m >> k;
vector <int> color(n), g[n], used(n);
set <int> colorUsed;
function <void(int, int, int)> dfs=[&](int v, int depth, const int &need) {
colorUsed.insert(color[v]);
if(depth == need) {
ans += (colorUsed.size() == need);
colorUsed.erase(color[v]);
return;
}
used[v] = 1;
for(auto u : g[v] ) {
if(!used[u]) dfs(u, depth + 1, need);
}
used[v]=0;
colorUsed.erase(color[v]);
};
for(int i = 0; i < n; i ++) cin >> color[i];
for(int i = 0; i < m; i ++) {
int u, v;
cin >> u >> v;
u --, v --;
g[u].push_back(v);
g[v].push_back(u);
}
for(int dist = 2; dist <= k; dist ++) {
for(int i = 0; i < n; i ++) {
dfs(i, 1, dist);
cout << "\n";
}
}
cout << ans;
return 0;
}
Compilation message
paths.cpp: In lambda function:
paths.cpp:18:29: warning: comparison of integer expressions of different signedness: 'std::set<long long int>::size_type' {aka 'long unsigned int'} and 'const long long int' [-Wsign-compare]
18 | ans += (colorUsed.size() == need);
| ~~~~~~~~~~~~~~~~~^~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2426 ms |
8104 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Execution timed out |
3044 ms |
2652 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |