Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
99824 柯昊阳 FBI树 C++ 运行出错 10 0 MS 312 KB 1195 2023-08-23 21:41:09

Tests(1/10):


#include <bits/stdc++.h> using namespace std; struct tree{ char val; tree *left; tree *right; }; string a; void digui(tree *s,vector<char> &z){ if(s!=nullptr){ digui(s->left,z); digui(s->right,z); z.push_back(s->val); } } tree* dg(int i,int j){ if(i<j){ tree *tmp1 = dg(i, (i+j)/2); tree *tmp2 = dg((i+j)/2+1, j); tree *node = new tree(); node->left = tmp1; node->right = tmp2; char s1 = tmp1->val; char s2 = tmp2->val; if(s1==s2&&s1!='F') { node->val = s1; } else{ node->val = 'F'; } } else{ tree *node = new tree(); node->left = nullptr; node->right = nullptr; if(a[i]=='1') { node->val = 'I'; } else { node->val = 'B'; } return node; } } int main(){ int n; cin>>n; cin>>a; tree *root=dg(0,a.size()-1); vector<char> ss; digui(root,ss); for(int i = 0;i<ss.size();i++){ cout<<ss[i]; } cout<<endl; return 0; }


测评信息: