# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1050747 | starr | Paths (BOI18_paths) | C++17 | 1 ms | 604 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
int n, m, k;
vector<int> adj[105], col(105);
int ans = 0;
void dfs(int nd, int cnt, vector<int> a){
a.push_back(col[nd]);
if(cnt > 4){
return;
}
else if (cnt >= 2){
vector<int> temp(6);
for(int i = 0; i < temp.size(); i++) temp[i] = 0;
int ada = 1;
for(auto x : a){
if(temp[x] == 1) ada = 0;
temp[x] = 1;
}
if(ada) ans++;
else return;
}
for(auto x : adj[nd]){
dfs(x, cnt + 1, a);
}
}
int main(){
cin >> n >> m >> k;
for(int i = 0; i < n; i++) cin >> col[i];
for(int i = 0; i < m; i++){
int a, b;
cin >> a >> b;
--a, --b;
adj[a].push_back(b);
adj[b].push_back(a);
}
for(int i = 0; i < n; i++){
dfs(i, 1, {});
}
cout << ans << endl;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |