Submission #1038856

# Submission time Handle Problem Language Result Execution time Memory
1038856 2024-07-30T08:23:24 Z fv3 Beech Tree (IOI23_beechtree) C++17
0 / 100
69 ms 17604 KB
#include <bits/stdc++.h>
#include "beechtree.h"

using namespace std;

vector<int> beechtree(int N, int M, vector<int> P, vector<int> C)
{
    vector<int> b(N);
    vector<vector<int>> adj(N);

    for (int i = 1; i < N; i++)
    {
        adj[P[i]].push_back(i);
    }

    map<int, int> colourCnt;
    for (auto node : adj[0])
    {
        b[node] = 1;
        set<int> childColours;
        for (auto e : adj[node])
        {
            if (childColours.count(C[e])) 
                b[node] = 0;
            childColours.insert(C[e]);
            colourCnt[C[e]]++;
            b[e] = 1;
        }
    }

    b[0] = 1;
    set<int> childColours;
    for (auto node : adj[0])
    {
        if (!b[node] || childColours.count(C[node]))
        {
            b[0] = 0;
            break;
        } 
        childColours.insert(C[node]);
    }

    vector<int> cnts;
    for (auto n : colourCnt)
    {
        if (childColours.count(n.first) == 0)
        {
            b[0] = 0;
            break;
        }
        cnts.push_back(n.second);
    }

    sort(cnts.begin(), cnts.end());
    for (int i = 0; i < cnts.size(); i++)
    {
        if (cnts[i] != i+1)
        {
            b[0] = 0;
            break;
        }
    }

    return b;
}

Compilation message

beechtree.cpp: In function 'std::vector<int> beechtree(int, int, std::vector<int>, std::vector<int>)':
beechtree.cpp:55:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |     for (int i = 0; i < cnts.size(); i++)
      |                     ~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 1 ms 348 KB 2nd lines differ - on the 4th token, expected: '0', found: '1'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 516 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Incorrect 1 ms 348 KB 2nd lines differ - on the 4th token, expected: '1', found: '0'
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 516 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Incorrect 1 ms 348 KB 2nd lines differ - on the 4th token, expected: '1', found: '0'
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Incorrect 0 ms 348 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 1 ms 516 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Incorrect 69 ms 17604 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 348 KB Output is correct
2 Incorrect 1 ms 348 KB 2nd lines differ - on the 4th token, expected: '0', found: '1'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 516 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Incorrect 0 ms 348 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 0 ms 348 KB Output is correct
2 Incorrect 1 ms 348 KB 2nd lines differ - on the 4th token, expected: '0', found: '1'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 516 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Incorrect 0 ms 348 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 0 ms 348 KB Output is correct
2 Incorrect 1 ms 348 KB 2nd lines differ - on the 4th token, expected: '0', found: '1'
3 Halted 0 ms 0 KB -