답안 #973480

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
973480 2024-05-02T05:12:44 Z irmuun 참나무 (IOI23_beechtree) C++17
0 / 100
2000 ms 348 KB
#include<bits/stdc++.h>
#include "beechtree.h"

using namespace std;

#define ll long long
#define pb push_back
#define ff first
#define ss second
#define all(s) s.begin(),s.end()
#define rall(s) s.rbegin(),s.rend()

vector<int>beechtree(int n,int m,vector<int>p,vector<int>c){
    vector<int>g[n];
    bool line=true;
    for(int i=1;i<n;i++){
        g[p[i]].pb(i);
        line&=(p[i]+1==i);
    }
    vector<int>b(n);
    if(line){
        bool ok=true;
        b[n-1]=1;
        for(int i=n-2;i>=0;i--){
            if(c[i]==c[i+1]){
                b[i]=1;
            }
            else{
                break;
            }
        }
        return b;
    }
    for(int i=1;i<n;i++){
        c[i]--;
    }
    vector<int>f(m);
    for(int r=0;r<n;r++){
        vector<int>u;
        queue<int>q;
        q.push(r);
        while(!q.empty()){
            int x=q.front();
            u.pb(x);
            q.pop();
            for(int y:g[x]){
                q.push(y);
            }
        }
        sort(all(u));
        bool can=false;
        do{
            fill(all(f),0);
            bool flag=true;
            if(u[0]!=r){
                continue;
            }
            for(int i=1;i<u.size();i++){
                if(p[u[i]]!=u[f[c[u[i]]]]){
                    flag=false;
                }
                f[c[u[i]]]++;
            }
            if(flag){
                can=true;
            }
        }while(next_permutation(all(u)));
        if(can){
            b[r]=1;
        }
    }
    return b;
}

Compilation message

beechtree.cpp: In function 'std::vector<int> beechtree(int, int, std::vector<int>, std::vector<int>)':
beechtree.cpp:22:14: warning: unused variable 'ok' [-Wunused-variable]
   22 |         bool ok=true;
      |              ^~
beechtree.cpp:58:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   58 |             for(int i=1;i<u.size();i++){
      |                         ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Execution timed out 2082 ms 348 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB 2nd lines differ - on the 1st token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB 2nd lines differ - on the 1st token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2068 ms 348 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB 2nd lines differ - on the 1st token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Execution timed out 2082 ms 348 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB 2nd lines differ - on the 1st token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Execution timed out 2082 ms 348 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB 2nd lines differ - on the 1st token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Execution timed out 2082 ms 348 KB Time limit exceeded
3 Halted 0 ms 0 KB -