Submission #848271

# Submission time Handle Problem Language Result Execution time Memory
848271 2023-09-11T23:17:18 Z Plurm Beech Tree (IOI23_beechtree) C++17
0 / 100
67 ms 26568 KB
#include "beechtree.h"
#include <bits/stdc++.h>
using namespace std;

vector<int> beechtree(int N, int M, vector<int> P, vector<int> C) {
  vector<int> dep(N);
  dep[0] = 0;
  vector<set<int>> chs(N);
  vector<int> d1c;
  d1c.resize(M + 1, 0);
  vector<int> d2c;
  d2c.resize(M + 1, 0);
  vector<int> ret;
  ret.resize(N, 1);
  bool flag = true;
  for (int i = 1; i < N; i++) {
    if (P[i] == 0)
      dep[i] = 1;
    else
      dep[i] = 2;
    if (chs[P[i]].count(C[i])) {
      ret[P[i]] = 0;
      flag = false;
    }
    chs[P[i]].insert(C[i]);
    if (dep[i] == 2) {
      d2c[C[i]]++;
    } else {
      d1c[C[i]]++;
    }
  }
  if (!flag)
    ret[0] = 0;
  vector<int> vs;
  for (int i = 1; i <= M; i++) {
    if (d2c[i] != 0 && d1c[i] == 0)
      ret[0] = 0;
    if (d2c[i] != 0)
      vs.push_back(d2c[i]);
  }
  sort(vs.begin(), vs.end());
  for (int i = 0; i < vs.size(); i++) {
    if (vs[i] < i)
      ret[0] = 0;
  }
  return ret;
}

Compilation message

beechtree.cpp: In function 'std::vector<int> beechtree(int, int, std::vector<int>, std::vector<int>)':
beechtree.cpp:42:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |   for (int i = 0; i < vs.size(); i++) {
      |                   ~~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 1 ms 344 KB 2nd lines differ - on the 1st token, expected: '0', found: '1'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Incorrect 0 ms 344 KB 2nd lines differ - on the 2nd token, expected: '0', found: '1'
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Incorrect 0 ms 344 KB 2nd lines differ - on the 2nd token, expected: '0', found: '1'
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Incorrect 2 ms 2136 KB 2nd lines differ - on the 1st token, expected: '0', found: '1'
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Incorrect 67 ms 26568 KB 2nd lines differ - on the 2nd token, expected: '0', found: '1'
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 1 ms 344 KB 2nd lines differ - on the 1st token, expected: '0', found: '1'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Incorrect 0 ms 344 KB 2nd lines differ - on the 1st token, expected: '0', found: '1'
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 1 ms 344 KB 2nd lines differ - on the 1st token, expected: '0', found: '1'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Incorrect 0 ms 344 KB 2nd lines differ - on the 1st token, expected: '0', found: '1'
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 1 ms 344 KB 2nd lines differ - on the 1st token, expected: '0', found: '1'
3 Halted 0 ms 0 KB -