답안 #1046462

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1046462 2024-08-06T15:11:52 Z Trustfulcomic 참나무 (IOI23_beechtree) C++17
0 / 100
2000 ms 22040 KB
#include "beechtree.h"

#include<bits/stdc++.h>
using namespace std;

int n,m;
vector<int> p,c;
vector<vector<int>> g;

int good(int r){
    vector<int> ch;
    queue<int> q; q.push(r);
    while(!q.empty()){
        int n = q.front(); q.pop();
        ch.push_back(n);
        for (int i : g[n]) q.push(i);
    }

    bool jupi = false;
    do {
        vector<int> count(m, 0);
        vector<int> is(ch.size(), -1);
        is[0] = r;
        bool good = true;

        for (int i = 0; i<ch.size() && good; i++){
            if (ch[i] == r) continue;
            if (p[ch[i]] != is[count[c[ch[i]]]]) good = false;
            count[c[ch[i]]]++;
            is[i+1]=ch[i];
        }

        if (good){
            jupi = true;
            break;
        }

    } while(next_permutation(ch.begin(), ch.end()));

    if (jupi) return 1;
    return 0;
}

std::vector<int> beechtree(int N, int M, std::vector<int> P, std::vector<int> C)
{   
    n = N;
    m = M;
    p = P;
    c = C;
    g.resize(n);
    for (int i = 1; i<n; i++){
        g[p[i]].push_back(i);
    }

    vector<int> res(n);
    for (int i = 0; i<n; i++){
        res[i] = good(i);
    }
    return res;
}

Compilation message

beechtree.cpp: In function 'int good(int)':
beechtree.cpp:26:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |         for (int i = 0; i<ch.size() && good; i++){
      |                         ~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Execution timed out 2086 ms 344 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Runtime error 1 ms 432 KB Execution killed with signal 6
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Runtime error 1 ms 432 KB Execution killed with signal 6
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2021 ms 344 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Execution timed out 2088 ms 22040 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Execution timed out 2086 ms 344 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 356 KB Output is correct
14 Runtime error 0 ms 348 KB Execution killed with signal 6
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Execution timed out 2086 ms 344 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 356 KB Output is correct
14 Runtime error 0 ms 348 KB Execution killed with signal 6
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Execution timed out 2086 ms 344 KB Time limit exceeded
3 Halted 0 ms 0 KB -