답안 #1078114

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1078114 2024-08-27T12:51:25 Z MohamedFaresNebili 참나무 (IOI23_beechtree) C++17
0 / 100
2000 ms 4956 KB
#include <bits/stdc++.h>
#include "beechtree.h"

        using namespace std;

        vector<int> adj[200005];

        void getSub(int v, vector<int>& sub) {
            sub.push_back(v);
            for(auto u : adj[v])
                getSub(u, sub);
        }

        vector<int> beechtree(int N, int M, vector<int> P, vector<int> C) {
            vector<int> ans(N, 0);
            for(int l = 0; l < N; l++) adj[l].clear();
            for(int l = 1; l < N; l++)
                adj[P[l]].push_back(l);
            for(int l = 0; l < N; l++) {
                vector<int> sub; getSub(l, sub);
                sort(sub.begin() + 1, sub.end());
                do {
                    bool ok = true;
                    vector<int> cur(M, 0);
                    for(int i = 0; i < sub.size() && ok; i++) {
                        if(i > 0) ok &= (P[sub[i]] == sub[cur[C[sub[i]]]]);
                        cur[C[sub[i]]]++;
                    }
                    if(ok) { ans[l] = 1; break; }
                } while(!next_permutation(sub.begin() + 1, sub.end()));
            }
            return ans;
        }




Compilation message

beechtree.cpp: In function 'std::vector<int> beechtree(int, int, std::vector<int>, std::vector<int>)':
beechtree.cpp:25:38: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |                     for(int i = 0; i < sub.size() && ok; i++) {
      |                                    ~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4956 KB Output is correct
2 Execution timed out 2092 ms 4956 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2032 ms 4952 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2032 ms 4952 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 4956 KB 2nd lines differ - on the 2nd token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2032 ms 4952 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4956 KB Output is correct
2 Execution timed out 2092 ms 4956 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2032 ms 4952 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4956 KB Output is correct
2 Execution timed out 2092 ms 4956 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2032 ms 4952 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4956 KB Output is correct
2 Execution timed out 2092 ms 4956 KB Time limit exceeded
3 Halted 0 ms 0 KB -