답안 #951706

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
951706 2024-03-22T11:16:04 Z mocha Paths (BOI18_paths) C++14
23 / 100
3000 ms 14940 KB
#include <bits/stdc++.h>
using namespace std;
const int mx = 3e5+5;

int n, m, K;
int a[mx];
vector<int> g[mx];
bool vis[mx];
set<int> st;
long long cnt;

void dfs(int x) {
	vis[x] = 1;
	st.insert(a[x]);
	cnt++;
	for (int i:g[x]) {
		if (!st.count(a[i]) and !vis[i]) {
			dfs(i);
		}
	}
	vis[x] = 0;
	st.erase(a[x]);
}

int main() {
	cin >> n >> m >> K;
	for (int i=1;i<=n;i++) {
		cin >> a[i];
	}
	for (int i=1;i<=m;i++) {
		int u, v;
		cin >> u >> v;
		g[u].push_back(v);
		g[v].push_back(u);
	}

	for (int i=1;i<=n;i++) {
		dfs(i);
	}
	cout << cnt - n << "\n";
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 8540 KB Output is correct
2 Correct 2 ms 8800 KB Output is correct
3 Correct 2 ms 8540 KB Output is correct
4 Correct 2 ms 8540 KB Output is correct
5 Correct 2 ms 8544 KB Output is correct
6 Correct 3 ms 8652 KB Output is correct
7 Correct 2 ms 8544 KB Output is correct
8 Correct 2 ms 8544 KB Output is correct
9 Correct 2 ms 8544 KB Output is correct
10 Correct 2 ms 8544 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3063 ms 14940 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 8540 KB Output is correct
2 Correct 2 ms 8800 KB Output is correct
3 Correct 2 ms 8540 KB Output is correct
4 Correct 2 ms 8540 KB Output is correct
5 Correct 2 ms 8544 KB Output is correct
6 Correct 3 ms 8652 KB Output is correct
7 Correct 2 ms 8544 KB Output is correct
8 Correct 2 ms 8544 KB Output is correct
9 Correct 2 ms 8544 KB Output is correct
10 Correct 2 ms 8544 KB Output is correct
11 Execution timed out 3063 ms 14940 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 8796 KB Output is correct
2 Execution timed out 3069 ms 10420 KB Time limit exceeded
3 Halted 0 ms 0 KB -