제출 #1233409

#제출 시각아이디문제언어결과실행 시간메모리
1233409yixuan19Team Coding (EGOI24_teamcoding)C++20
0 / 100
7 ms16196 KiB
#include <iostream> #include <vector> #include <utility> #include <algorithm> using namespace std; const int taille = 2001; vector<int> depth(taille,0); vector<vector<int> > child(taille); vector <int> languages; vector <vector<int> > levels(taille, vector<int> (taille,0)); void dfs(int node){ for (int c: child[node]){ depth[c] = depth[node]+1; dfs(c); } } int score = 0; int swaps = 0; vector<int> used(taille,0); int dfs2(int node, int lang){ //cout<<"calling "<<node<<' '<<lang<<' '<<score<<endl; if (languages[node] == lang && levels[depth[node]][lang] - used[depth[node]] > 0){ score++; used[depth[node]]++; }else if (languages[node] == lang && levels[depth[node]][lang] - used[depth[node]] == 0){ swaps--; }else{ if (levels[depth[node]][lang] - used[depth[node]] > 0){ score++; levels[depth[node]][lang]--; swaps++; } } for (int c: child[node]){ dfs2(c, lang); } } int main(){ int N, K, lang, boss; cin >> N >> K; for (int i = 0; i < N; ++i){ cin >> lang; languages.push_back(lang); } for (int i = 1; i <= N-1; ++i){ cin >> boss; child[boss].push_back(i); } dfs(0); }

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

Main.cpp: In function 'int dfs2(int, int)':
Main.cpp:39:1: warning: no return statement in function returning non-void [-Wreturn-type]
   39 | }
      | ^
#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...