# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
473315 | 2021-09-15T12:01:09 Z | ZaZo_ | Paths (BOI18_paths) | C++14 | 3000 ms | 127992 KB |
#include <bits/stdc++.h> #define ZAZO ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); #define int long long using namespace std; int n , m , k; int cols[300001],vis[300001]; vector<int>edges[300001]; set<vector<int>>ans; void dfs(int node,set<int>path,vector<int>path2,int par) { if(path2.size()==0){ path2.push_back(node); path.insert(cols[node]); } for(int i = 0 ; i < edges[node].size() ; i++) { if(edges[node][i]!=par && !path.count(cols[edges[node][i]])&&path.size()<k ){ path.insert(cols[edges[node][i]]); path2.push_back(edges[node][i]); ans.insert(path2); dfs(edges[node][i] , path , path2 , node); path2.erase(path2.begin()+(path2.size()-1)); path.erase(cols[edges[node][i]]); } } } int32_t main() { ZAZO cin >> n >> m >> k ; for(int i = 1 ; i <= n ; i++) { cin>>cols[i]; } for(int i = 0 ; i < m ; i++) { int u , v; cin >> u >> v; edges[u].push_back(v); edges[v].push_back(u); } for(int i = 1 ; i <= n ; i++) { dfs(i,{},{},-1); } cout<<ans.size()<<endl; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 7500 KB | Output is correct |
2 | Correct | 5 ms | 7372 KB | Output is correct |
3 | Correct | 5 ms | 7372 KB | Output is correct |
4 | Correct | 5 ms | 7372 KB | Output is correct |
5 | Correct | 4 ms | 7372 KB | Output is correct |
6 | Correct | 6 ms | 7628 KB | Output is correct |
7 | Correct | 6 ms | 7500 KB | Output is correct |
8 | Correct | 5 ms | 7372 KB | Output is correct |
9 | Correct | 5 ms | 7372 KB | Output is correct |
10 | Correct | 5 ms | 7372 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 3060 ms | 127992 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 7500 KB | Output is correct |
2 | Correct | 5 ms | 7372 KB | Output is correct |
3 | Correct | 5 ms | 7372 KB | Output is correct |
4 | Correct | 5 ms | 7372 KB | Output is correct |
5 | Correct | 4 ms | 7372 KB | Output is correct |
6 | Correct | 6 ms | 7628 KB | Output is correct |
7 | Correct | 6 ms | 7500 KB | Output is correct |
8 | Correct | 5 ms | 7372 KB | Output is correct |
9 | Correct | 5 ms | 7372 KB | Output is correct |
10 | Correct | 5 ms | 7372 KB | Output is correct |
11 | Execution timed out | 3060 ms | 127992 KB | Time limit exceeded |
12 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 7372 KB | Output is correct |
2 | Execution timed out | 3061 ms | 50844 KB | Time limit exceeded |
3 | Halted | 0 ms | 0 KB | - |