Submission #848269

# Submission time Handle Problem Language Result Execution time Memory
848269 2023-09-11T23:08:46 Z Plurm Beech Tree (IOI23_beechtree) C++17
0 / 100
1 ms 600 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 (d1c[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 0 ms 348 KB Output is correct
2 Incorrect 0 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 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 348 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 1 ms 348 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 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 600 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 Incorrect 0 ms 344 KB 2nd lines differ - on the 1st token, expected: '1', found: '0'
10 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 344 KB Output is correct
4 Incorrect 0 ms 344 KB 2nd lines differ - on the 1st token, expected: '1', found: '0'
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 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 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Incorrect 0 ms 344 KB 2nd lines differ - on the 1st token, expected: '1', found: '0'
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 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 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Incorrect 0 ms 344 KB 2nd lines differ - on the 1st token, expected: '1', found: '0'
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 344 KB 2nd lines differ - on the 1st token, expected: '0', found: '1'
3 Halted 0 ms 0 KB -