Submission #518383

# Submission time Handle Problem Language Result Execution time Memory
518383 2022-01-23T15:55:14 Z Ierus Paths (BOI18_paths) C++17
Compilation error
0 ms 0 KB
#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 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 = 3e5+324;
const int MOD = 1e9+7;
long long res;
int n, m, k, c[N];
vector<int> g[N];
long long cnt[5][N][(1<<4)];
void Count(int v, int x){
	for(auto to : g[v]){
		if(c[to] == c[v]) continue;
		for(int mask = 0; mask < (1 << k); ++mask){
			if(((mask >> c[v]) & 1)) continue;
			cnt[x][v][mask|(1<<c[v])] += cnt[x-1][to][mask];
		};
	};
}
int main(){
	ios_base::sync_with_stdio(0) , cin.tie(0) , cout.tie(0) ;
	cin >> n >> m >> k;
	for(int i = 1; i <= n; ++i){
		cin >> c[i]; --c[i];
		cnt[1][i][(1<<c[i])] = 1;
	}
	for(int i = 1; i <= m; ++i){
		int x, y;
		cin >> x >> y;
		g[x].pb(y);
		g[y].pb(x);
	}
	for(int i = 2; i <= k; ++i){
		for(int i = 1; i <= n; ++i){
			Count(i, x);
		}
	}
	long long sum = 0;
	for(int kk = 1; kk <= k; ++kk){
		for(int i = 1; i <= n; ++i){
			for(int j = 0;  j < (1 << k); ++j){
				sum += cnt[kk][i][j];
			}
		}
	}
	cout << sum - n;
}









Compilation message

paths.cpp: In function 'int main()':
paths.cpp:46:13: error: 'x' was not declared in this scope
   46 |    Count(i, x);
      |             ^