Submission #563633

#TimeUsernameProblemLanguageResultExecution timeMemory
563633Abrar_Al_SamitPaths (BOI18_paths)C++17
23 / 100
3064 ms13788 KiB
#include<bits/stdc++.h> using namespace std; const int MX = 3e5 + 5; vector<int>g[MX]; int n, m, k; int tag[MX]; long long ans = 0; int cur[6]; void solve(int v, bool first = 0) { if(cur[tag[v]]) return; cur[tag[v]] = 1; if(!first) ++ans; //cerr<<"v = "<<v<<endl; for(auto u : g[v]) { //cerr<<u<<endl; solve(u); } cur[tag[v]] = 0; } void PlayGround() { cin>>n>>m>>k; for(int i=1; i<=n; ++i) { cin>>tag[i]; } for(int i=0; i<m; ++i) { int u, v; cin>>u>>v; g[u].push_back(v); g[v].push_back(u); } //solve(1); //solve(2, 1); for(int i=1; i<=n; ++i) { solve(i, 1); //cout<<ans<<endl; } cout<<ans<<'\n'; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); PlayGround(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...