社区讨论
80分,一个点RE求调
P1032[NOIP 2002 提高组] 字串变换(疑似错题)参与者 2已保存回复 3
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 3 条
- 当前快照
- 1 份
- 快照标识符
- @mdq0ogs3
- 此快照首次捕获于
- 2025/07/30 21:44 7 个月前
- 此快照最后确认于
- 2025/11/04 05:42 4 个月前
CPP
#include<bits/stdc++.h>
using namespace std;
int n,h,t=1;
string a,b,ca[1001],cb[1001];
struct node {
int cnt;
string s;
} q[2000001];
main() {
cin>>a>>b;
while(cin>>ca[n]>>cb[n]) {
n++;
}
q[1].s=a,q[1].cnt=0;
while(h<t) {
if(q[h].cnt>10){
cout<<"NO ANSWER!";
return 0;
}
++h;
for(int i=0; i<n; i++) {
int id=q[h].s.find(ca[i],0);
while(1+1==2) {
if(id==-1) {
break;
} else {
++t;
q[t].cnt=q[h].cnt+1;
q[t].s=q[h].s;
q[t].s.replace(id,ca[i].size(),cb[i]);
if(q[t].s==b) {
cout<<q[t].cnt;
return 0;
}
id=q[t].s.find(ca[i],id+1);
}
}
}
}
}
回复
共 3 条回复,欢迎继续交流。
正在加载回复...