pdd不会有比我更惨的了
第二题本地调试粘贴过去忘记注释文件读入了。。。
有没有大佬能帮我看看代码别的地方有什么问题不?
#include <iostream> #include<cstdio> #include<cstring> #include<vector> using namespace std; vector<string>totans; void dfs(string &strN, string &strM, string &strD, string &ans) { if (strM == strD) { ans.pop_back(); totans.push_back(ans); return; } if (strN.length() == 0) { return; } string strN0 = strN, strD0 = strD, ans0 = ans + "d "; dfs(strN0.erase(0,1), strM, strD0, ans0); strN0 = strN, strD0 = strD, ans0 = ans +"r "; strN0.erase(0,1), strD0=strD0+strN.substr(0,1); dfs(strN0, strM, strD0, ans0); strN0 = strN, strD0 = strD, ans0 = ans +"l "; strN0.erase(0,1), strD0 = strD0.insert(0, strN.substr(0,1)); dfs(strN0, strM, strD0, ans0); } int main(int argc, char *argv[]) { int n ; freopen("cin.txt","r",stdin); scanf("%d",&n); for (int i = 0; i < n; i ++) { totans.clear(); string strN,strM,t=""; cin>>strN>>strM; //cout<<"strN:"<<strN<<" strM "<<strM.substr(0,1)<<endl; dfs(strN,strM,t,t); sort(totans.begin(), totans.end()); cout<<"{"<<endl; for (int i = 0; i < totans.size(); i ++) { cout<<totans[i]<<endl; } cout<<"}"<<endl; } }