![](//图.tk/0)
by hank0402 @ 2021-12-08 22:20:35
@[hank0402](/user/482642) 替换 `s` 的子串时,为什么从用 `s1` 找到的下标开始?
```diff
string s1 = s;
s1.replace(num, a1[i].size(), b1[i]);
q.push((Person){ d + 1, s1 });
- num = s1.find(a1[i], num + 1);
+ num = s.find(a1[i], num + 1);
}
}
}
```
另附无关的编译警告:
```plain
main.cpp: In function 'void solve()':
main.cpp:12:27: warning: ISO C++ forbids compound-literals [-Wpedantic]
12 | q.push((Person){ 0, a });
| ^
main.cpp:35:44: warning: ISO C++ forbids compound-literals [-Wpedantic]
35 | q.push((Person){ d + 1, s1 });
| ^
main.cpp: In function 'int main()':
main.cpp:44:36: warning: operation on 'tmp' may be undefined [-Wsequence-point]
44 | while (cin >> a1[tmp] >> b1[tmp++])
| ~~~^~
```
by ud2_ @ 2021-12-08 22:35:11
@[ud2_](/user/206953) 谢谢大佬!orz
by hank0402 @ 2021-12-10 13:09:48
@[ud2_](/user/206953) thank
by ydongy @ 2023-11-03 22:38:49