# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
973480 | 2024-05-02T05:12:44 Z | irmuun | Beech Tree (IOI23_beechtree) | C++17 | 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
# | Verdict | Execution time | Memory | 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 | - |
# | Verdict | Execution time | Memory | 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 | - |
# | Verdict | Execution time | Memory | 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 | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 2068 ms | 348 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | 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 | - |
# | Verdict | Execution time | Memory | 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 | - |
# | Verdict | Execution time | Memory | 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 | - |
# | Verdict | Execution time | Memory | 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 | - |
# | Verdict | Execution time | Memory | 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 | - |
# | Verdict | Execution time | Memory | 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 | - |