Submission #999682

# Submission time Handle Problem Language Result Execution time Memory
999682 2024-06-16T04:47:42 Z 김은성(#10860) Beech Tree (IOI23_beechtree) C++17
9 / 100
2000 ms 47444 KB
#include "beechtree.h"
#include <bits/stdc++.h>
using namespace std;
vector<int> graph[200009];
int c[200009];
int ans[200009];
int p[200009];
vector<int> dfs(int v){
    int i, j;
    vector<int> vec;
    for(i=0; i<graph[v].size(); i++){
        vector<int> temp = dfs(graph[v][i]);
        for(j=0; j<temp.size(); j++)
            vec.push_back(temp[j]);
    }
    vec.push_back(v);
    sort(vec.begin(), vec.end());
    while(1){
        bool flag = 1;
        if(vec[0] != v)
            flag = 0;
        for(i=1; i<vec.size(); i++){
            int cnt = 0;
            for(j=1; j<i; j++){
                if(c[vec[j]] == c[vec[i]])
                    cnt++;
            }
            if(vec[cnt] != p[vec[i]])
                flag = 0;
        }
        if(flag){
            ans[v] = 1;
            break;
        }
        if(!next_permutation(vec.begin(), vec.end()))
            break;
    }
    return vec;
}
std::vector<int> beechtree(int N, int M, std::vector<int> P, std::vector<int> C){
    int i;
    for(i=1; i<N; i++){
        graph[P[i]].push_back(i);
        c[i] = C[i];
        p[i] = P[i];
    }
    dfs(0);
    vector<int> res;
    for(i=0; i<N; i++)
        res.push_back(ans[i]);
    return res;
}

Compilation message

beechtree.cpp: In function 'std::vector<int> dfs(int)':
beechtree.cpp:11:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 |     for(i=0; i<graph[v].size(); i++){
      |              ~^~~~~~~~~~~~~~~~
beechtree.cpp:13:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 |         for(j=0; j<temp.size(); j++)
      |                  ~^~~~~~~~~~~~
beechtree.cpp:22:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |         for(i=1; i<vec.size(); i++){
      |                  ~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 7512 KB Output is correct
2 Execution timed out 2095 ms 7256 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 7260 KB Output is correct
2 Correct 1 ms 7260 KB Output is correct
3 Correct 1 ms 7256 KB Output is correct
4 Correct 2 ms 7260 KB Output is correct
5 Correct 2 ms 7260 KB Output is correct
6 Correct 3 ms 7260 KB Output is correct
7 Correct 1 ms 7260 KB Output is correct
8 Correct 2 ms 7260 KB Output is correct
9 Correct 2 ms 7260 KB Output is correct
10 Correct 2 ms 7312 KB Output is correct
11 Correct 2 ms 7260 KB Output is correct
12 Correct 1 ms 7260 KB Output is correct
13 Correct 1 ms 7260 KB Output is correct
14 Correct 1 ms 7260 KB Output is correct
15 Correct 2 ms 7260 KB Output is correct
16 Correct 1 ms 7260 KB Output is correct
17 Correct 2 ms 7260 KB Output is correct
18 Correct 1 ms 7260 KB Output is correct
19 Correct 1 ms 7260 KB Output is correct
20 Correct 1 ms 7260 KB Output is correct
21 Correct 1 ms 7260 KB Output is correct
22 Correct 2 ms 7260 KB Output is correct
23 Correct 2 ms 7260 KB Output is correct
24 Correct 1 ms 7260 KB Output is correct
25 Correct 1 ms 7256 KB Output is correct
26 Correct 2 ms 7256 KB Output is correct
27 Correct 1 ms 7260 KB Output is correct
28 Correct 1 ms 7260 KB Output is correct
29 Correct 1 ms 7260 KB Output is correct
30 Correct 1 ms 7260 KB Output is correct
31 Correct 1 ms 7260 KB Output is correct
32 Correct 2 ms 7260 KB Output is correct
33 Correct 1 ms 7260 KB Output is correct
34 Correct 1 ms 7260 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 7260 KB Output is correct
2 Correct 1 ms 7260 KB Output is correct
3 Correct 1 ms 7256 KB Output is correct
4 Correct 2 ms 7260 KB Output is correct
5 Correct 2 ms 7260 KB Output is correct
6 Correct 3 ms 7260 KB Output is correct
7 Execution timed out 2052 ms 47444 KB Time limit exceeded
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2008 ms 7256 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 7260 KB Output is correct
2 Correct 1 ms 7260 KB Output is correct
3 Correct 1 ms 7260 KB Output is correct
4 Correct 2 ms 7260 KB Output is correct
5 Execution timed out 2052 ms 47444 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 7512 KB Output is correct
2 Execution timed out 2095 ms 7256 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 7260 KB Output is correct
2 Correct 1 ms 7260 KB Output is correct
3 Correct 1 ms 7260 KB Output is correct
4 Correct 2 ms 7260 KB Output is correct
5 Correct 2 ms 7260 KB Output is correct
6 Correct 2 ms 7312 KB Output is correct
7 Correct 2 ms 7260 KB Output is correct
8 Correct 1 ms 7260 KB Output is correct
9 Correct 1 ms 7260 KB Output is correct
10 Correct 1 ms 7260 KB Output is correct
11 Correct 2 ms 7260 KB Output is correct
12 Correct 1 ms 7260 KB Output is correct
13 Correct 2 ms 7260 KB Output is correct
14 Correct 1 ms 7260 KB Output is correct
15 Correct 1 ms 7260 KB Output is correct
16 Correct 1 ms 7260 KB Output is correct
17 Correct 1 ms 7260 KB Output is correct
18 Correct 2 ms 7260 KB Output is correct
19 Correct 2 ms 7260 KB Output is correct
20 Correct 1 ms 7260 KB Output is correct
21 Correct 1 ms 7256 KB Output is correct
22 Correct 2 ms 7256 KB Output is correct
23 Correct 1 ms 7260 KB Output is correct
24 Correct 1 ms 7260 KB Output is correct
25 Correct 697 ms 7704 KB Output is correct
26 Execution timed out 2076 ms 7760 KB Time limit exceeded
27 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 7512 KB Output is correct
2 Execution timed out 2095 ms 7256 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 7260 KB Output is correct
2 Correct 1 ms 7260 KB Output is correct
3 Correct 1 ms 7260 KB Output is correct
4 Correct 2 ms 7260 KB Output is correct
5 Correct 2 ms 7260 KB Output is correct
6 Correct 2 ms 7312 KB Output is correct
7 Correct 2 ms 7260 KB Output is correct
8 Correct 1 ms 7260 KB Output is correct
9 Correct 1 ms 7260 KB Output is correct
10 Correct 1 ms 7260 KB Output is correct
11 Correct 2 ms 7260 KB Output is correct
12 Correct 1 ms 7260 KB Output is correct
13 Correct 2 ms 7260 KB Output is correct
14 Correct 1 ms 7260 KB Output is correct
15 Correct 1 ms 7260 KB Output is correct
16 Correct 1 ms 7260 KB Output is correct
17 Correct 1 ms 7260 KB Output is correct
18 Correct 2 ms 7260 KB Output is correct
19 Correct 2 ms 7260 KB Output is correct
20 Correct 1 ms 7260 KB Output is correct
21 Correct 1 ms 7256 KB Output is correct
22 Correct 2 ms 7256 KB Output is correct
23 Correct 1 ms 7260 KB Output is correct
24 Correct 1 ms 7260 KB Output is correct
25 Correct 697 ms 7704 KB Output is correct
26 Execution timed out 2076 ms 7760 KB Time limit exceeded
27 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 7512 KB Output is correct
2 Execution timed out 2095 ms 7256 KB Time limit exceeded
3 Halted 0 ms 0 KB -