답안 #518273

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
518273 2022-01-23T09:48:56 Z Ierus Paths (BOI18_paths) C++17
0 / 100
1 ms 312 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 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;
}
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';
}









# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 208 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 292 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 208 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Output is correct
2 Incorrect 1 ms 312 KB Output isn't correct
3 Halted 0 ms 0 KB -