Submission #987407

# Submission time Handle Problem Language Result Execution time Memory
987407 2024-05-22T17:28:10 Z activedeltorre Beech Tree (IOI23_beechtree) C++17
0 / 100
2000 ms 20180 KB
#include "beechtree.h"
#include <vector>
#include <queue>
#include <iostream>
#include <map>
using namespace std;
vector<int>cop[200005];
int cul[200005];
int imp[200005];
int dist[200005];
int par[200005];
vector<int>vecus;
bool cmp(int a,int b)
{
    //if(dist[a]==dist[b])
  //  {
        return cop[a].size()>cop[b].size();
  //  }
  //  return dist[a]<dist[b];
}
map<int,int>mp;
map<int,int>mp2;
int calc(int curr)
{
    mp2.clear();
    int cur;
    queue<int>qu;
    dist[curr]=0;
    qu.push(curr);
    vecus.clear();
    while(qu.size())
    {
        cur=qu.front();
        vecus.push_back(cur);
        qu.pop();
        for(auto k:cop[cur])
        {
            dist[k]=dist[curr]+1;
            qu.push(k);
        }
    }
    //cout<<curr<<" "<<imp[curr]<<"   :";
    for(auto i:vecus)
    {
        if(i!=curr)
        {
        if(par[i]!=vecus[mp2[cul[i]]])
        {
            return 0;
        }
        mp2[cul[i]]++;
        }
    }
  //  cout<<'\n';
    return 1;
}
std::vector<int> beechtree(int N, int M, std::vector<int> P, std::vector<int> C)
{
    int n=N,culs=M,i;
    vector<int>ans;
    for(i=1;i<n;i++)
    {
        par[i]=P[i];
        cop[P[i]].push_back(i);
        cul[i]=C[i];
    }
    for(i=0;i<n;i++)
    {
        mp.clear();
        for(auto k:cop[i])
        {
            mp[cul[k]]++;
            if(mp[cul[k]]==2)
            {
                imp[i]=1;
            }
        }
    }
    for(i=0;i<n ;i++)
    {
        ans.push_back(calc(i));
    }
    return ans;
}

Compilation message

beechtree.cpp: In function 'std::vector<int> beechtree(int, int, std::vector<int>, std::vector<int>)':
beechtree.cpp:59:13: warning: unused variable 'culs' [-Wunused-variable]
   59 |     int n=N,culs=M,i;
      |             ^~~~
# Verdict Execution time Memory Grader output
1 Correct 3 ms 8028 KB Output is correct
2 Correct 2 ms 8028 KB Output is correct
3 Correct 3 ms 8028 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 8028 KB Output is correct
2 Correct 3 ms 8028 KB Output is correct
3 Correct 2 ms 8024 KB Output is correct
4 Correct 3 ms 8028 KB Output is correct
5 Correct 3 ms 8028 KB Output is correct
6 Correct 3 ms 8028 KB Output is correct
7 Correct 3 ms 8184 KB Output is correct
8 Correct 3 ms 8024 KB Output is correct
9 Correct 3 ms 8024 KB Output is correct
10 Correct 3 ms 8024 KB Output is correct
11 Correct 3 ms 8028 KB Output is correct
12 Correct 2 ms 8028 KB Output is correct
13 Correct 3 ms 8024 KB Output is correct
14 Correct 2 ms 8028 KB Output is correct
15 Correct 3 ms 8024 KB Output is correct
16 Correct 3 ms 8280 KB Output is correct
17 Correct 4 ms 8028 KB Output is correct
18 Correct 3 ms 8028 KB Output is correct
19 Correct 3 ms 8028 KB Output is correct
20 Incorrect 3 ms 8028 KB 2nd lines differ - on the 1st token, expected: '1', found: '0'
21 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 8028 KB Output is correct
2 Correct 3 ms 8028 KB Output is correct
3 Correct 2 ms 8024 KB Output is correct
4 Correct 3 ms 8028 KB Output is correct
5 Correct 3 ms 8028 KB Output is correct
6 Correct 3 ms 8028 KB Output is correct
7 Execution timed out 2045 ms 20180 KB Time limit exceeded
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 8024 KB Output is correct
2 Correct 2 ms 8024 KB Output is correct
3 Correct 2 ms 8028 KB Output is correct
4 Correct 2 ms 7860 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 8028 KB Output is correct
8 Correct 3 ms 8028 KB Output is correct
9 Incorrect 4 ms 8028 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 3 ms 8028 KB Output is correct
2 Correct 3 ms 8028 KB Output is correct
3 Correct 3 ms 8184 KB Output is correct
4 Correct 3 ms 8024 KB Output is correct
5 Execution timed out 2045 ms 20180 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 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 3 ms 8028 KB Output is correct
5 Correct 3 ms 8028 KB Output is correct
6 Correct 2 ms 8024 KB Output is correct
7 Correct 3 ms 8028 KB Output is correct
8 Correct 3 ms 8028 KB Output is correct
9 Correct 3 ms 8028 KB Output is correct
10 Correct 3 ms 8184 KB Output is correct
11 Correct 3 ms 8024 KB Output is correct
12 Correct 3 ms 8024 KB Output is correct
13 Correct 3 ms 8024 KB Output is correct
14 Correct 3 ms 8028 KB Output is correct
15 Correct 2 ms 8028 KB Output is correct
16 Correct 3 ms 8024 KB Output is correct
17 Correct 2 ms 8028 KB Output is correct
18 Correct 3 ms 8024 KB Output is correct
19 Correct 3 ms 8280 KB Output is correct
20 Correct 4 ms 8028 KB Output is correct
21 Correct 3 ms 8028 KB Output is correct
22 Correct 3 ms 8028 KB Output is correct
23 Incorrect 3 ms 8028 KB 2nd lines differ - on the 1st token, expected: '1', found: '0'
24 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 8028 KB Output is correct
2 Correct 3 ms 8028 KB Output is correct
3 Correct 3 ms 8184 KB Output is correct
4 Correct 3 ms 8024 KB Output is correct
5 Correct 3 ms 8024 KB Output is correct
6 Correct 3 ms 8024 KB Output is correct
7 Correct 3 ms 8028 KB Output is correct
8 Correct 2 ms 8028 KB Output is correct
9 Correct 3 ms 8024 KB Output is correct
10 Correct 2 ms 8028 KB Output is correct
11 Correct 3 ms 8024 KB Output is correct
12 Correct 3 ms 8280 KB Output is correct
13 Correct 4 ms 8028 KB Output is correct
14 Correct 3 ms 8028 KB Output is correct
15 Correct 3 ms 8028 KB Output is correct
16 Incorrect 3 ms 8028 KB 2nd lines differ - on the 1st token, expected: '1', found: '0'
17 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 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 3 ms 8028 KB Output is correct
5 Correct 3 ms 8028 KB Output is correct
6 Correct 2 ms 8024 KB Output is correct
7 Correct 3 ms 8028 KB Output is correct
8 Correct 3 ms 8028 KB Output is correct
9 Correct 3 ms 8028 KB Output is correct
10 Correct 3 ms 8184 KB Output is correct
11 Correct 3 ms 8024 KB Output is correct
12 Correct 3 ms 8024 KB Output is correct
13 Correct 3 ms 8024 KB Output is correct
14 Correct 3 ms 8028 KB Output is correct
15 Correct 2 ms 8028 KB Output is correct
16 Correct 3 ms 8024 KB Output is correct
17 Correct 2 ms 8028 KB Output is correct
18 Correct 3 ms 8024 KB Output is correct
19 Correct 3 ms 8280 KB Output is correct
20 Correct 4 ms 8028 KB Output is correct
21 Correct 3 ms 8028 KB Output is correct
22 Correct 3 ms 8028 KB Output is correct
23 Incorrect 3 ms 8028 KB 2nd lines differ - on the 1st token, expected: '1', found: '0'
24 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 8028 KB Output is correct
2 Correct 3 ms 8028 KB Output is correct
3 Correct 3 ms 8184 KB Output is correct
4 Correct 3 ms 8024 KB Output is correct
5 Correct 3 ms 8024 KB Output is correct
6 Correct 3 ms 8024 KB Output is correct
7 Correct 3 ms 8028 KB Output is correct
8 Correct 2 ms 8028 KB Output is correct
9 Correct 3 ms 8024 KB Output is correct
10 Correct 2 ms 8028 KB Output is correct
11 Correct 3 ms 8024 KB Output is correct
12 Correct 3 ms 8280 KB Output is correct
13 Correct 4 ms 8028 KB Output is correct
14 Correct 3 ms 8028 KB Output is correct
15 Correct 3 ms 8028 KB Output is correct
16 Incorrect 3 ms 8028 KB 2nd lines differ - on the 1st token, expected: '1', found: '0'
17 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 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 3 ms 8028 KB Output is correct
5 Correct 3 ms 8028 KB Output is correct
6 Correct 2 ms 8024 KB Output is correct
7 Correct 3 ms 8028 KB Output is correct
8 Correct 3 ms 8028 KB Output is correct
9 Correct 3 ms 8028 KB Output is correct
10 Correct 3 ms 8184 KB Output is correct
11 Correct 3 ms 8024 KB Output is correct
12 Correct 3 ms 8024 KB Output is correct
13 Correct 3 ms 8024 KB Output is correct
14 Correct 3 ms 8028 KB Output is correct
15 Correct 2 ms 8028 KB Output is correct
16 Correct 3 ms 8024 KB Output is correct
17 Correct 2 ms 8028 KB Output is correct
18 Correct 3 ms 8024 KB Output is correct
19 Correct 3 ms 8280 KB Output is correct
20 Correct 4 ms 8028 KB Output is correct
21 Correct 3 ms 8028 KB Output is correct
22 Correct 3 ms 8028 KB Output is correct
23 Incorrect 3 ms 8028 KB 2nd lines differ - on the 1st token, expected: '1', found: '0'
24 Halted 0 ms 0 KB -