Submission #518274

#TimeUsernameProblemLanguageResultExecution timeMemory
518274IerusPaths (BOI18_paths)C++17
23 / 100
1 ms296 KiB
#include<bits/stdc++.h> using namespace std; #pragma GCC optimize ("unroll-loops,Ofast,O3") #pragma GCC target("avx,avx2,fma") #define F first #define S second #define sz(x) (int)x.size() #define pb push_back #define eb emplace_back #define all(x) (x).begin(),(x).end() #define rall(x) (x).rbegin(),(x).rend() #define NFS ios_base::sync_with_stdio(0) , cin.tie(0) , cout.tie(0) ; #define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout) typedef long long ll; const int E = 1e6+777; const long long inf = 1e18+777; const int N = 177; const int MOD = 1e9+7; int n, m, k, c[N]; vector<int> g[N]; vector <bool> color(6), used(N); int sum; void dfs(int v, int h){ used[v] = true; color[c[v]] = true; if(h > 1){ // cerr << "v: " << v << '\n'; ++sum; // return; } // cerr << "to("<<v<<")\n"; // for(auto to : g[v]){ // if(!color[c[to]] && !used[to]){ // cerr << to << " "; // } // } // cerr << "\n"; for(auto it : g[v]){ if(!color[c[it]] && !used[it]){ dfs(it, h + 1); } } color[c[v]] = false; used[v] = false; } int main(){ cin >> n >> m >> k; for(int i = 1; i <= n; ++i){ cin >> c[i]; } for(int i = 1; i <= m; ++i){ int x, y; cin >> x >> y; g[x].pb(y); g[y].pb(x); } for(int i = 1; i <= n; ++i){ used.assign(n+3, 0); // cerr << "dfs: " << i << '\n'; dfs(i, 1); } cout << sum << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...