제출 #993455

#제출 시각아이디문제언어결과실행 시간메모리
993455THXuan9월 (APIO24_september)C++17
45 / 100
126 ms37704 KiB
#include "september.h" #include <bits/stdc++.h> #define INF 1e18 using namespace std; typedef long long ll; vector<int>adj[800005]; int dp[800005]; 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]); } } int solve(int N, int M, vector<int> F, vector<vector<int>>S) { for(int i = 0;i<N;i++){ adj[i].clear(); dp[i] = 0; } for(int i =1; i < N;i++){ adj[i].push_back(F[i]); adj[F[i]].push_back(i); //cout << i << " "<< F[i] << "\n"; } for(int i = 0;i<S[0].size();i++){ dp[S[0][i]] = i; } dfs(0, -1); int ans = 0; int i=0; while(i < S[0].size()){ int j = dp[S[0][i]]; int maxn = dp[S[0][i]]; int k = i; while(k <= maxn){ maxn = max(maxn, dp[S[0][k]]); ++k; } ++ans; i = maxn + 1; } return ans; }

컴파일 시 표준 에러 (stderr) 메시지

september.cpp: In function 'int solve(int, int, std::vector<int>, std::vector<std::vector<int> >)':
september.cpp:28:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 | for(int i = 0;i<S[0].size();i++){
      |               ~^~~~~~~~~~~~
september.cpp:33:9: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 | while(i < S[0].size()){
      |       ~~^~~~~~~~~~~~~
september.cpp:34:5: warning: unused variable 'j' [-Wunused-variable]
   34 | int j = dp[S[0][i]];
      |     ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...