# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
863374 |
2023-10-20T06:02:44 Z |
maks007 |
Paths (BOI18_paths) |
C++14 |
|
3000 ms |
22608 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, changes = 1;
cin >> n >> m >> k;
vector <int> color(n), g[n], used(n), permutation(k);
set <int> colorUsed;
function <void(int, int)> dfs=[&](int v, int cur) {
if(cur >= changes) {
ans++;
}
if(cur == permutation.size() - 1) return;
used[v] = 1;
for(auto u : g[v] ) {
if(!used[u] && color[u] == permutation[cur+1]) dfs(u, cur + 1);
}
used[v]=0;
};
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);
}
vector <int> prev;
for(int i = 0; i < k; i ++) permutation[i] = i + 1;
do{
/*if(prev.size() > 0) {
for(int i = 0; i < permutation.size(); i ++) {
if(prev[i] != permutation[i]) {
changes = i;
break;
}
}
changes = max(changes, 1LL);
}*/
for(int i = 0; i < n; i ++) {
if(color[i] == permutation[0]) dfs(i, 0);
}
//prev = permutation;
} while(next_permutation(permutation.begin(), permutation.end()));
cout << ans;
return 0;
}
Compilation message
paths.cpp: In lambda function:
paths.cpp:19:10: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
19 | if(cur == permutation.size() - 1) return;
| ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# |
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 |
419 ms |
7820 KB |
Output is correct |
2 |
Correct |
2121 ms |
7764 KB |
Output is correct |
3 |
Correct |
258 ms |
22608 KB |
Output is correct |
4 |
Correct |
67 ms |
9580 KB |
Output is correct |
5 |
Correct |
78 ms |
9700 KB |
Output is correct |
6 |
Execution timed out |
3053 ms |
17064 KB |
Time limit exceeded |
7 |
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 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |