Submission #862910

# Submission time Handle Problem Language Result Execution time Memory
862910 2023-10-19T11:07:33 Z faustaadp Beech Tree (IOI23_beechtree) C++17
9 / 100
113 ms 31540 KB
#include "beechtree.h"
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
const ll NN = 2e5 + 5;
vector<pll> v[NN];
ll ada[NN], ade[NN];
std::vector<int> beechtree(int N, int M, std::vector<int> P, std::vector<int> C)
{
    vector<int> ret(N, 0);
    for(ll i = 1; i < N; i++)
        v[P[i]].pb(mp(i, C[i]));
    ret[0] = 1;
    {
        vector<ll> tmp;
        for(auto a : v[0])
        {
            ada[a.se] = 1;
            tmp.pb(a.se);
        }
        sort(tmp.begin(), tmp.end());
        for(ll j = 1; j < tmp.size(); j++)
            if(tmp[j - 1] == tmp[j])
                ret[0] = 0;
    }

    vector<pair<ll, vector<ll> > > vv;
    for(ll i = 1; i < N; i++)
        if(v[i].size() == 0)
            ret[i] = 1;
        else
        {
            ret[i] = 1;
            vector<ll> tmp;
            for(auto a : v[i])
                tmp.pb(a.se);
            sort(tmp.begin(), tmp.end());
            for(ll j = 0; j < tmp.size(); j++)
            {
                if(!ada[tmp[j]])
                    ret[0] = 0;
            }
            for(ll j = 1; j < tmp.size(); j++)
                if(tmp[j - 1] == tmp[j])
                {
                    ret[0] = 0;
                    ret[i] = 0;
                }
            vv.pb(mp((ll)tmp.size(), tmp));
        }
    sort(vv.begin(), vv.end());
    for(ll i = 1; i < vv.size(); i++)
    {
        for(auto a : vv[i].se)ade[a] = i;
        for(auto a : vv[i - 1].se)
            if(ade[a] != 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:27:25: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |         for(ll j = 1; j < tmp.size(); j++)
      |                       ~~^~~~~~~~~~~~
beechtree.cpp:43:29: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |             for(ll j = 0; j < tmp.size(); j++)
      |                           ~~^~~~~~~~~~~~
beechtree.cpp:48:29: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   48 |             for(ll j = 1; j < tmp.size(); j++)
      |                           ~~^~~~~~~~~~~~
beechtree.cpp:57:21: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<std::pair<long long int, std::vector<long long int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   57 |     for(ll i = 1; i < vv.size(); i++)
      |                   ~~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 8024 KB Output is correct
2 Incorrect 2 ms 8028 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 2 ms 8024 KB Output is correct
2 Correct 2 ms 8028 KB Output is correct
3 Correct 2 ms 8028 KB Output is correct
4 Correct 2 ms 8028 KB Output is correct
5 Incorrect 2 ms 8024 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 8024 KB Output is correct
2 Correct 2 ms 8028 KB Output is correct
3 Correct 2 ms 8028 KB Output is correct
4 Correct 2 ms 8028 KB Output is correct
5 Incorrect 2 ms 8024 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 8028 KB Output is correct
2 Correct 2 ms 8028 KB Output is correct
3 Correct 3 ms 8028 KB Output is correct
4 Correct 2 ms 8028 KB Output is correct
5 Correct 2 ms 8028 KB Output is correct
6 Correct 2 ms 8028 KB Output is correct
7 Correct 2 ms 8284 KB Output is correct
8 Correct 2 ms 8028 KB Output is correct
9 Correct 2 ms 8024 KB Output is correct
10 Correct 2 ms 8028 KB Output is correct
11 Correct 2 ms 8100 KB Output is correct
12 Correct 2 ms 8028 KB Output is correct
13 Correct 2 ms 8120 KB Output is correct
14 Correct 2 ms 8028 KB Output is correct
15 Correct 31 ms 13952 KB Output is correct
16 Correct 30 ms 13660 KB Output is correct
17 Correct 29 ms 13652 KB Output is correct
18 Correct 32 ms 13808 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 8024 KB Output is correct
2 Correct 2 ms 8028 KB Output is correct
3 Correct 2 ms 8028 KB Output is correct
4 Correct 2 ms 8056 KB Output is correct
5 Incorrect 113 ms 31540 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 8024 KB Output is correct
2 Incorrect 2 ms 8028 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 2 ms 8024 KB Output is correct
2 Correct 2 ms 8028 KB Output is correct
3 Correct 2 ms 8028 KB Output is correct
4 Correct 2 ms 8056 KB Output is correct
5 Incorrect 2 ms 8024 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 2 ms 8024 KB Output is correct
2 Incorrect 2 ms 8028 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 2 ms 8024 KB Output is correct
2 Correct 2 ms 8028 KB Output is correct
3 Correct 2 ms 8028 KB Output is correct
4 Correct 2 ms 8056 KB Output is correct
5 Incorrect 2 ms 8024 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 2 ms 8024 KB Output is correct
2 Incorrect 2 ms 8028 KB 2nd lines differ - on the 4th token, expected: '0', found: '1'
3 Halted 0 ms 0 KB -