Submission #645464

#TimeUsernameProblemLanguageResultExecution timeMemory
645464mychecksedadPaths (BOI18_paths)C++17
23 / 100
62 ms30228 KiB
/* Author : Mychecksdead */ #include<bits/stdc++.h> using namespace std; typedef long long int ll; typedef long double ld; #define MOD (1000000000+7) #define MOD1 (998244353) #define PI 3.1415926535 #define pb push_back #define setp() cout << setprecision(15) #define all(x) x.begin(), x.end() #define debug(x) cerr << #x << " is " << x << '\n'; const int N = 1e6+100, M = 1e5+10, F = 2147483646, K = 20; int n, m, k, a[N]; ll ans = 0; vector<int> g[N]; void dfs1(int v, int p, int d, vector<int> &x){ if(d>1){ ans++; } for(int u: g[v]){ if(u != p){ if(x[a[u]]) continue; x[a[u]] = 1; dfs1(u, v, d + 1, x); x[a[u]] = 0; } } } void solve(){ cin >> n >> m >> k; for(int i = 1; i <= n; ++i) cin >> a[i]; for(int i = 1; i <= n; ++i) --a[i]; for(int i = 0; i < m; ++i){ int u, v; cin >> u >> v; g[u].pb(v); g[v].pb(u); } if(n <= 100){ vector<int> v (4); for(int i = 1; i <= n; ++i){ v[0] = v[1] = v[2] = v[3] = 0; v[a[i]] = 1; dfs1(i, 0, 1, v); } }else{ } cout << ans; } int main(){ cin.tie(0); ios::sync_with_stdio(0); int T = 1, aa; // cin >> T;aa=T; while(T--){ // cout << "Case #" << aa-T << ": "; solve(); cout << '\n'; } return 0; }

Compilation message (stderr)

paths.cpp: In function 'int main()':
paths.cpp:66:16: warning: unused variable 'aa' [-Wunused-variable]
   66 |     int T = 1, aa;
      |                ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...