제출 #1124147

#제출 시각아이디문제언어결과실행 시간메모리
1124147EfeBabagilHomework (CEOI22_homework)C++20
10 / 100
1100 ms109140 KiB
#include <stdio.h> #include <bits/stdc++.h> using namespace std; string s; int cur; vector<int> v; struct tree { char node; tree* left; tree* right; }; tree* parse() { if(s[cur] == '?') { cur++; return new tree{'?',nullptr,nullptr}; } tree* l; tree* r; char n; n=s[cur+1]; cur+=4; l = parse(); cur++; r = parse(); cur++; return new tree{n,l,r}; } int dfs(tree* x) { if(x->node=='?') { return v[cur++]; } if(x->node=='i') { return min(dfs(x->left),dfs(x->right)); } if(x->node=='a') { return max(dfs(x->left),dfs(x->right)); } } int main() { cin>>s; int n=(s.size()+6)/7; auto root=parse(); vector<bool> ans(n+1); for(int i=0;i<n;i++) v.push_back(i+1); vector<int> temp=v; do { cur=0; ans[dfs(root)]=1; }while (next_permutation(v.begin(), v.end())); int tot=0; for(int i=1;i<n+1;i++) { if(ans[i]==1) tot++; } cout<<tot; return 0; }

컴파일 시 표준 에러 (stderr) 메시지

Main.cpp: In function 'int dfs(tree*)':
Main.cpp:48:1: warning: control reaches end of non-void function [-Wreturn-type]
   48 | }
      | ^
#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...