Submission #999697

# Submission time Handle Problem Language Result Execution time Memory
999697 2024-06-16T05:21:15 Z 김은성(#10860) Beech Tree (IOI23_beechtree) C++17
5 / 100
50 ms 13524 KB
#include "beechtree.h"
#include <bits/stdc++.h>
using namespace std;
vector<int> graph[200009];
int c[200009];
bool 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;
    ans[N-1] = 1;
    ans[N-2] = 1;
    for(i=N-3; i>=0; i--){
        ans[i] = (ans[i+1] && (C[i+1] == C[N-1]));
    }
    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 Incorrect 1 ms 6492 KB 2nd lines differ - on the 2nd token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 6492 KB Output is correct
2 Correct 1 ms 6492 KB Output is correct
3 Correct 1 ms 6492 KB Output is correct
4 Correct 1 ms 6492 KB Output is correct
5 Correct 1 ms 6492 KB Output is correct
6 Correct 1 ms 6492 KB Output is correct
7 Incorrect 2 ms 6492 KB 2nd lines differ - on the 1st token, expected: '0', found: '1'
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 6492 KB Output is correct
2 Correct 1 ms 6492 KB Output is correct
3 Correct 1 ms 6492 KB Output is correct
4 Correct 1 ms 6492 KB Output is correct
5 Correct 1 ms 6492 KB Output is correct
6 Correct 1 ms 6492 KB Output is correct
7 Correct 41 ms 10956 KB Output is correct
8 Correct 42 ms 13396 KB Output is correct
9 Correct 1 ms 6492 KB Output is correct
10 Correct 1 ms 6492 KB Output is correct
11 Correct 1 ms 6492 KB Output is correct
12 Correct 1 ms 6492 KB Output is correct
13 Correct 2 ms 6748 KB Output is correct
14 Correct 2 ms 6748 KB Output is correct
15 Correct 2 ms 6748 KB Output is correct
16 Correct 1 ms 6748 KB Output is correct
17 Correct 38 ms 13020 KB Output is correct
18 Correct 39 ms 13260 KB Output is correct
19 Correct 42 ms 13524 KB Output is correct
20 Correct 50 ms 13516 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 6488 KB 2nd lines differ - on the 2nd token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 6492 KB Output is correct
2 Correct 1 ms 6492 KB Output is correct
3 Incorrect 2 ms 6492 KB 2nd lines differ - on the 1st token, expected: '0', found: '1'
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 6492 KB 2nd lines differ - on the 2nd token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 6492 KB Output is correct
2 Correct 1 ms 6492 KB Output is correct
3 Incorrect 2 ms 6492 KB 2nd lines differ - on the 1st token, expected: '0', found: '1'
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 6492 KB 2nd lines differ - on the 2nd token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 6492 KB Output is correct
2 Correct 1 ms 6492 KB Output is correct
3 Incorrect 2 ms 6492 KB 2nd lines differ - on the 1st token, expected: '0', found: '1'
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 6492 KB 2nd lines differ - on the 2nd token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -