답안 #993467

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
993467 2024-06-05T17:45:28 Z THXuan 9월 (APIO24_september) C++17
컴파일 오류
0 ms 0 KB
#include "september.h"
#include "september.h"
#include <bits/stdc++.h>
#define INF 1e18
using namespace std;
typedef long long ll;

vector<int>adj[100005];
int dp[100005];

void dfs(int s, int e){
	for(auto u : adj[s]){
		if(u==e) continue;
		dfs(u, s);
		dp[s] = max(dp[s], dp[u]);
	}
}

ll solve(int N, int M, vector<int> F, vector<vector<int>>S) {
	for(int i = 0;i<N;i++){
		adj[i].clear();
	}
	for(int i =1; i < N;i++){
		adj[i].push_back(F[i]);
		adj[F[i]].push_back(i);
		//cout << i << " "<< F[i] << "\n";
	}
	ll ans = INF;
	for(int c = 0;c<M;c++){
		for(int i =0;i<S[c].size();i++){
			dp[S[c][i]]=i;
		}
		dfs(0, -1);
		ll anss = 0; int i=0;
		while(i < S[c].size()){
		int j = dp[S[c][i]];
		int maxn = dp[S[c][i]];
		int k = i;
		while(k <= maxn){
			maxn = max(maxn, dp[S[c][k]]);
			++k;
		}
		++ans;
		i = maxn + 1;
		}
		ans = min(ans, anss);
	}
	return ans;
}

Compilation message

september.cpp:19:4: error: ambiguating new declaration of 'll solve(int, int, std::vector<int>, std::vector<std::vector<int> >)'
   19 | ll solve(int N, int M, vector<int> F, vector<vector<int>>S) {
      |    ^~~~~
In file included from september.cpp:2:
september.h:3:5: note: old declaration 'int solve(int, int, std::vector<int>, std::vector<std::vector<int> >)'
    3 | int solve(int N, int M, std::vector<int> F, std::vector<std::vector<int>> S);
      |     ^~~~~
september.cpp: In function 'll solve(int, int, std::vector<int>, std::vector<std::vector<int> >)':
september.cpp:30:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |   for(int i =0;i<S[c].size();i++){
      |                ~^~~~~~~~~~~~
september.cpp:35:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |   while(i < S[c].size()){
      |         ~~^~~~~~~~~~~~~
september.cpp:36:7: warning: unused variable 'j' [-Wunused-variable]
   36 |   int j = dp[S[c][i]];
      |       ^