Submission #973482

#TimeUsernameProblemLanguageResultExecution timeMemory
973482irmuunBeech Tree (IOI23_beechtree)C++17
14 / 100
2077 ms17756 KiB
#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; b[n-2]=1; for(int i=n-3;i>=0;i--){ if(c[i+1]==c[i+2]){ 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 (stderr)

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:59:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   59 |             for(int i=1;i<u.size();i++){
      |                         ~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...