Submission #863410

#TimeUsernameProblemLanguageResultExecution timeMemory
863410maks007Paths (BOI18_paths)C++14
0 / 100
3044 ms8104 KiB
// 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 (stderr)

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...