이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
const int N = 3e5;
int n, m, col[N+1];
int k;
vector<int> g[N+1];
int ans;
int used[N+10], used_c[N+10];
int timer = 1, closed;
void dfs(int v){
used[v] = timer, used_c[col[v]] = timer;
ans++;
if(closed == k){
used[v] = timer-1, used_c[col[v]] = timer-1, closed--;
return;
}
for(int to : g[v]){
if(used[to] !=timer && used_c[col[to]] != timer){
closed++;
dfs(to);
closed--;
}
}
used[v] = timer-1, used_c[col[v]] = timer-1;
}
main(){
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> n >> m >> k;
for(int i = 1;i <= n; i++){
cin >> col[i];
}
for(int i = 0;i < m; i++){
int a, b; cin >> a >> b;
g[a].push_back(b);
g[b].push_back(a);
}
for(int i = 1;i <= n; i++){
closed = 1;
dfs(i);
ans--;
timer++;
}
cout << ans;
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
paths.cpp:33:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
33 | main(){
| ^~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |