| Run ID | 作者 | 问题 | 语言 | 测评结果 | 时间 | 内存 | 代码长度 | 提交时间 |
|---|---|---|---|---|---|---|---|---|
| 81138 | sh25_zhuwy | 求先序排列 | C++ | 通过 | 0 MS | 248 KB | 464 | 2026-01-04 15:39:47 |
#include <bits/stdc++.h> using namespace std ; string s , s2 ; int ans = 0 ; void dfs(int b , int e , int root ) { if(e < b) return ; int t ; for(int i = b ; i <= e ; i++ ) if(s[i] == s2[root]) { t = i ; cout << s2[root]; break ; } dfs(b , t - 1 , root - 1 - e + t ) ; dfs(t + 1 , e , root - 1 ) ; } int main() { cin >> s >> s2 ; int n = s.size() ; s = " " + s ; s2 = " " + s2 ; dfs(1 , n , n ) ; return 0 ; }