답안 #1047077

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1047077 2024-08-07T08:38:21 Z Abito 참나무 (IOI23_beechtree) C++17
9 / 100
2000 ms 27084 KB
#include "beechtree.h"
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
const int N=2e5+5;
int a[N],c[N],p[N],n,f[505];
vector<int> adj[N],s;
void dfs(int x){
    s.pb(x);
    for (auto u:adj[x]) dfs(u);
    return;
}
int check(int x){
    dfs(x);
    if (s.size()==1){
        s.clear();
        return 1;
    }
    sort(s.begin(),s.end());
    //cout<<x<<endl;
    //for (auto u:s) cout<<u<<' ';cout<<endl;
    bool ok=0;
    do{
        if (s[0]!=x) continue;
        bool h=1;
        for (int i=1;i<s.size();i++){
            if (f[c[s[i]]]>=s.size()){
                h=0;
                break;
            }
            if (s[f[c[s[i]]]]==p[s[i]]){
                f[c[s[i]]]++;
                continue;
            }
            h=0;
            break;
        }
        ok|=h;
        memset(f,0,sizeof(f));
    }while (next_permutation(s.begin(),s.end()));
    s.clear();
    return ok;
}
vector<int> beechtree(int N, int M, vector<int> P, vector<int> C)
{
    n=N;
    vector<int> ans(n,0);
    for (int i=0;i<n;i++) p[i]=P[i],c[i]=C[i];
    for (int i=1;i<n;i++) adj[p[i]].pb(i);
    for (int i=0;i<n;i++) ans[i]=check(i);
    return ans;
}

Compilation message

beechtree.cpp: In function 'int check(int)':
beechtree.cpp:26:23: 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=1;i<s.size();i++){
      |                      ~^~~~~~~~~
beechtree.cpp:27:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |             if (f[c[s[i]]]>=s.size()){
      |                 ~~~~~~~~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 6748 KB Output is correct
2 Execution timed out 2089 ms 6748 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 6748 KB Output is correct
2 Correct 1 ms 6748 KB Output is correct
3 Correct 1 ms 6748 KB Output is correct
4 Correct 1 ms 6748 KB Output is correct
5 Correct 1 ms 6748 KB Output is correct
6 Correct 2 ms 6748 KB Output is correct
7 Correct 1 ms 6748 KB Output is correct
8 Correct 1 ms 6776 KB Output is correct
9 Correct 1 ms 6748 KB Output is correct
10 Correct 1 ms 6748 KB Output is correct
11 Correct 1 ms 6748 KB Output is correct
12 Correct 1 ms 6748 KB Output is correct
13 Correct 1 ms 6748 KB Output is correct
14 Correct 1 ms 6748 KB Output is correct
15 Correct 1 ms 6748 KB Output is correct
16 Correct 1 ms 6748 KB Output is correct
17 Correct 1 ms 6748 KB Output is correct
18 Correct 1 ms 6748 KB Output is correct
19 Correct 1 ms 6752 KB Output is correct
20 Correct 1 ms 6748 KB Output is correct
21 Correct 1 ms 6748 KB Output is correct
22 Correct 1 ms 6760 KB Output is correct
23 Correct 1 ms 6752 KB Output is correct
24 Correct 1 ms 6752 KB Output is correct
25 Correct 1 ms 6752 KB Output is correct
26 Correct 1 ms 6748 KB Output is correct
27 Correct 1 ms 6784 KB Output is correct
28 Correct 1 ms 6752 KB Output is correct
29 Correct 1 ms 6748 KB Output is correct
30 Correct 1 ms 6752 KB Output is correct
31 Correct 1 ms 6748 KB Output is correct
32 Correct 1 ms 6748 KB Output is correct
33 Correct 1 ms 6748 KB Output is correct
34 Correct 1 ms 6748 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 6748 KB Output is correct
2 Correct 1 ms 6748 KB Output is correct
3 Correct 1 ms 6748 KB Output is correct
4 Correct 1 ms 6748 KB Output is correct
5 Correct 1 ms 6748 KB Output is correct
6 Correct 2 ms 6748 KB Output is correct
7 Execution timed out 2019 ms 27084 KB Time limit exceeded
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2056 ms 6744 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 6748 KB Output is correct
2 Correct 1 ms 6748 KB Output is correct
3 Correct 1 ms 6748 KB Output is correct
4 Correct 1 ms 6776 KB Output is correct
5 Execution timed out 2019 ms 27084 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 6748 KB Output is correct
2 Execution timed out 2089 ms 6748 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 6748 KB Output is correct
2 Correct 1 ms 6748 KB Output is correct
3 Correct 1 ms 6748 KB Output is correct
4 Correct 1 ms 6776 KB Output is correct
5 Correct 1 ms 6748 KB Output is correct
6 Correct 1 ms 6748 KB Output is correct
7 Correct 1 ms 6748 KB Output is correct
8 Correct 1 ms 6748 KB Output is correct
9 Correct 1 ms 6748 KB Output is correct
10 Correct 1 ms 6748 KB Output is correct
11 Correct 1 ms 6748 KB Output is correct
12 Correct 1 ms 6748 KB Output is correct
13 Correct 1 ms 6748 KB Output is correct
14 Correct 1 ms 6748 KB Output is correct
15 Correct 1 ms 6752 KB Output is correct
16 Correct 1 ms 6748 KB Output is correct
17 Correct 1 ms 6748 KB Output is correct
18 Correct 1 ms 6760 KB Output is correct
19 Correct 1 ms 6752 KB Output is correct
20 Correct 1 ms 6752 KB Output is correct
21 Correct 1 ms 6752 KB Output is correct
22 Correct 1 ms 6748 KB Output is correct
23 Correct 1 ms 6784 KB Output is correct
24 Correct 1 ms 6752 KB Output is correct
25 Execution timed out 2094 ms 6780 KB Time limit exceeded
26 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 6748 KB Output is correct
2 Execution timed out 2089 ms 6748 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 6748 KB Output is correct
2 Correct 1 ms 6748 KB Output is correct
3 Correct 1 ms 6748 KB Output is correct
4 Correct 1 ms 6776 KB Output is correct
5 Correct 1 ms 6748 KB Output is correct
6 Correct 1 ms 6748 KB Output is correct
7 Correct 1 ms 6748 KB Output is correct
8 Correct 1 ms 6748 KB Output is correct
9 Correct 1 ms 6748 KB Output is correct
10 Correct 1 ms 6748 KB Output is correct
11 Correct 1 ms 6748 KB Output is correct
12 Correct 1 ms 6748 KB Output is correct
13 Correct 1 ms 6748 KB Output is correct
14 Correct 1 ms 6748 KB Output is correct
15 Correct 1 ms 6752 KB Output is correct
16 Correct 1 ms 6748 KB Output is correct
17 Correct 1 ms 6748 KB Output is correct
18 Correct 1 ms 6760 KB Output is correct
19 Correct 1 ms 6752 KB Output is correct
20 Correct 1 ms 6752 KB Output is correct
21 Correct 1 ms 6752 KB Output is correct
22 Correct 1 ms 6748 KB Output is correct
23 Correct 1 ms 6784 KB Output is correct
24 Correct 1 ms 6752 KB Output is correct
25 Execution timed out 2094 ms 6780 KB Time limit exceeded
26 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 6748 KB Output is correct
2 Execution timed out 2089 ms 6748 KB Time limit exceeded
3 Halted 0 ms 0 KB -