Submission #355379

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
3553792021-01-22 12:25:30spatarelCat in a tree (BOI17_catinatree)C++17
51 / 100
12 ms9324 KiB
#include <stdio.h>
#include <algorithm>
#include <vector>
const int MAX_N = 1500; // 200000
int N, D;
std::vector<int> children[MAX_N];
int maxN[MAX_N][1 + MAX_N];
int depth[MAX_N];
void dfs(int u) {
depth[u] = 1;
//int deepestChild = -1;
for (int v : children[u]) {
dfs(v);
if (depth[u] < 1 + depth[v]) {
depth[u] = 1 + depth[v];
//deepestChild = v;
}
}
maxN[u][0] = 1;
for (int v : children[u]) {
maxN[u][0] += maxN[v][D - 1];
}
std::vector<int> maxAdd(1 + D);
for (int v : children[u]) {
for (int d = 0; d < D && d < depth[v]; d++) {
maxN[u][d + 1] += maxN[v][d];
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Compilation message (stderr)

catinatree.cpp: In function 'int main()':
catinatree.cpp:52:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   52 |   scanf("%d%d", &N, &D);
      |   ~~~~~^~~~~~~~~~~~~~~~
catinatree.cpp:55:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   55 |     scanf("%d", &xi);
      |     ~~~~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...