제출 #1160519

#제출 시각아이디문제언어결과실행 시간메모리
1160519jus_tengSeptember (APIO24_september)C++20
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; vector<vector<ll>> buildTree(ll N, vector<ll>& P) { vector<vector<ll>> adj(N); for (ll i = 1; i < N; i++) { adj[P[i]].push_back(i); } return adj; } void findLeaves(ll node, vector<vector<ll>>& adj, vector<ll>& leaves) { if (adj[node].empty() && node != 0) { leaves.push_back(node); } for (ll child : adj[node]) { findLeaves(child, adj, leaves); } } int solve(ll N, ll M, vector<ll> P, vector<vector<ll>> S) { // Build adjacency list from parent array vector<vector<ll>> adj = buildTree(N, P); // Identify all leaf nodes vector<ll> leaves; findLeaves(0, adj, leaves); sort(leaves.begin(), leaves.end()); // Handle edge cases if (leaves.size() <= 1) return leaves.size(); ll maxDays = 0; // Try all permutations of leaf falling order do { vector<queue<ll>> sequences(M); for (ll i = 0; i < M; i++) { for (ll leaf : S[i]) { sequences[i].push(leaf); } } ll days = 1; bool valid = true; // Simulate leaf falling for (ll leaf : leaves) { bool matched = false; for (ll v = 0; v < M; v++) { if (!sequences[v].empty() && sequences[v].front() == leaf) { sequences[v].pop(); matched = true; break; } } if (!matched) { days++; // New day if no volunteer expected this leaf } } // Verify all sequences are exhausted for (ll v = 0; v < M; v++) { if (!sequences[v].empty()) { valid = false; break; } } if (valid) { maxDays = max(maxDays, days); } } while (next_permutation(leaves.begin(), leaves.end())); return maxDays; }

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

/usr/bin/ld: /tmp/ccIZlLvz.o: in function `mtbpdhr2zxjo1o4i9oreohsbuzzl4s6u::taskcase()':
grader.cpp:(.text+0x50d): undefined reference to `solve(int, int, std::vector<int, std::allocator<int> >, std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >)'
collect2: error: ld returned 1 exit status