Submission #1063246

# Submission time Handle Problem Language Result Execution time Memory
1063246 2024-08-17T15:44:20 Z De3b0o Beech Tree (IOI23_beechtree) C++17
9 / 100
2000 ms 31112 KB
#include "beechtree.h"
#include<bits/stdc++.h>
#include<random>
#define ll long long
#define F first
#define S second
#define in insert
#define pb push_back
#define ppb pop_back()
#define d3 ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define cans cout << ans << "\n";
#define yes cout << "Yes" << "\n";
#define no cout << "No" << "\n";
#define pll pair<ll,ll>
#define lin cout << "\n";
#define sqr 340
#define mod 1000000007
#define mid ((l+r)/2)
#define lc (2*x)
#define rc (2*x+1)
#define sq 547

using namespace std;

vector<ll> adj[200009];
ll n , m;
ll p[200009] , c[200009];
vector<ll> v;

void dfs(ll x , ll pr)
{
    v.pb(x);
    for(auto it : adj[x])
    {
        if(it==pr)
            continue;
        dfs(it,x);
    }
}

std::vector<int> beechtree(int N, int M, std::vector<int> P, std::vector<int> C)
{
    n=N;
    m=M;
    for(int i = 1 ; n>i ; i++)
    {
        adj[i].pb(P[i]);
        adj[P[i]].pb(i);
    }
    for(int i = 0 ; n>i ; i++)
    {
        p[i]=P[i];
        c[i]=C[i];
    }
    vector<int> ans;
    for(int i = 0 ; n>i ; i++)
    {
        v.clear();
        dfs(i,p[i]);
        bool g = 0;
        sort(v.begin(),v.end());
        do
        {
            if(v[0]!=i)
                continue;
            bool gg = 1;
            for(int j = 1 ; v.size()>j ; j++)
            {
                ll x = 0;
                for(int h = 1 ; j>h ; h++)
                {
                    if(c[v[h]]==c[v[j]])
                        x++;
                }
                if(p[v[j]]!=v[x])
                    gg=0;
            }
            if(gg)
                g=1;
        }
        while(next_permutation(v.begin(),v.end()));
        ans.pb(g);
    }
    return ans;
}

Compilation message

beechtree.cpp: In function 'std::vector<int> beechtree(int, int, std::vector<int>, std::vector<int>)':
beechtree.cpp:67:37: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   67 |             for(int j = 1 ; v.size()>j ; j++)
      |                             ~~~~~~~~^~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4952 KB Output is correct
2 Execution timed out 2094 ms 4956 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4952 KB Output is correct
2 Correct 2 ms 4956 KB Output is correct
3 Correct 2 ms 4952 KB Output is correct
4 Correct 2 ms 4956 KB Output is correct
5 Correct 3 ms 4956 KB Output is correct
6 Correct 2 ms 4956 KB Output is correct
7 Correct 2 ms 4956 KB Output is correct
8 Correct 2 ms 4956 KB Output is correct
9 Correct 2 ms 4952 KB Output is correct
10 Correct 2 ms 4956 KB Output is correct
11 Correct 2 ms 4956 KB Output is correct
12 Correct 2 ms 4956 KB Output is correct
13 Correct 2 ms 4992 KB Output is correct
14 Correct 2 ms 4956 KB Output is correct
15 Correct 3 ms 4952 KB Output is correct
16 Correct 2 ms 4956 KB Output is correct
17 Correct 2 ms 4956 KB Output is correct
18 Correct 2 ms 5072 KB Output is correct
19 Correct 2 ms 4956 KB Output is correct
20 Correct 2 ms 4952 KB Output is correct
21 Correct 2 ms 4956 KB Output is correct
22 Correct 2 ms 5000 KB Output is correct
23 Correct 3 ms 4956 KB Output is correct
24 Correct 2 ms 4952 KB Output is correct
25 Correct 2 ms 4952 KB Output is correct
26 Correct 3 ms 5140 KB Output is correct
27 Correct 2 ms 4952 KB Output is correct
28 Correct 2 ms 4956 KB Output is correct
29 Correct 2 ms 4956 KB Output is correct
30 Correct 2 ms 4956 KB Output is correct
31 Correct 2 ms 4956 KB Output is correct
32 Correct 3 ms 4952 KB Output is correct
33 Correct 2 ms 5208 KB Output is correct
34 Correct 2 ms 4956 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4952 KB Output is correct
2 Correct 2 ms 4956 KB Output is correct
3 Correct 2 ms 4952 KB Output is correct
4 Correct 2 ms 4956 KB Output is correct
5 Correct 3 ms 4956 KB Output is correct
6 Correct 2 ms 4956 KB Output is correct
7 Execution timed out 2064 ms 31112 KB Time limit exceeded
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2023 ms 4956 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4952 KB Output is correct
2 Correct 2 ms 4956 KB Output is correct
3 Correct 2 ms 4956 KB Output is correct
4 Correct 2 ms 4956 KB Output is correct
5 Execution timed out 2064 ms 31112 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4952 KB Output is correct
2 Execution timed out 2094 ms 4956 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4952 KB Output is correct
2 Correct 2 ms 4956 KB Output is correct
3 Correct 2 ms 4956 KB Output is correct
4 Correct 2 ms 4956 KB Output is correct
5 Correct 2 ms 4952 KB Output is correct
6 Correct 2 ms 4956 KB Output is correct
7 Correct 2 ms 4956 KB Output is correct
8 Correct 2 ms 4956 KB Output is correct
9 Correct 2 ms 4992 KB Output is correct
10 Correct 2 ms 4956 KB Output is correct
11 Correct 3 ms 4952 KB Output is correct
12 Correct 2 ms 4956 KB Output is correct
13 Correct 2 ms 4956 KB Output is correct
14 Correct 2 ms 5072 KB Output is correct
15 Correct 2 ms 4956 KB Output is correct
16 Correct 2 ms 4952 KB Output is correct
17 Correct 2 ms 4956 KB Output is correct
18 Correct 2 ms 5000 KB Output is correct
19 Correct 3 ms 4956 KB Output is correct
20 Correct 2 ms 4952 KB Output is correct
21 Correct 2 ms 4952 KB Output is correct
22 Correct 3 ms 5140 KB Output is correct
23 Correct 2 ms 4952 KB Output is correct
24 Correct 2 ms 4956 KB Output is correct
25 Execution timed out 2037 ms 5156 KB Time limit exceeded
26 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4952 KB Output is correct
2 Execution timed out 2094 ms 4956 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4952 KB Output is correct
2 Correct 2 ms 4956 KB Output is correct
3 Correct 2 ms 4956 KB Output is correct
4 Correct 2 ms 4956 KB Output is correct
5 Correct 2 ms 4952 KB Output is correct
6 Correct 2 ms 4956 KB Output is correct
7 Correct 2 ms 4956 KB Output is correct
8 Correct 2 ms 4956 KB Output is correct
9 Correct 2 ms 4992 KB Output is correct
10 Correct 2 ms 4956 KB Output is correct
11 Correct 3 ms 4952 KB Output is correct
12 Correct 2 ms 4956 KB Output is correct
13 Correct 2 ms 4956 KB Output is correct
14 Correct 2 ms 5072 KB Output is correct
15 Correct 2 ms 4956 KB Output is correct
16 Correct 2 ms 4952 KB Output is correct
17 Correct 2 ms 4956 KB Output is correct
18 Correct 2 ms 5000 KB Output is correct
19 Correct 3 ms 4956 KB Output is correct
20 Correct 2 ms 4952 KB Output is correct
21 Correct 2 ms 4952 KB Output is correct
22 Correct 3 ms 5140 KB Output is correct
23 Correct 2 ms 4952 KB Output is correct
24 Correct 2 ms 4956 KB Output is correct
25 Execution timed out 2037 ms 5156 KB Time limit exceeded
26 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4952 KB Output is correct
2 Execution timed out 2094 ms 4956 KB Time limit exceeded
3 Halted 0 ms 0 KB -