社区讨论
听灌佬多
灌水区参与者 3已保存回复 4
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 4 条
- 当前快照
- 1 份
- 快照标识符
- @lyo5hamb
- 此快照首次捕获于
- 2024/07/16 16:27 2 年前
- 此快照最后确认于
- 2024/07/16 17:11 2 年前
P1019
CPP5
at
touch
cheat
choose
tact
terminate called after throwing an instance of 'std::out_of_range'
what(): basic_string::substr: __pos (which is 18446744073709551615) > this->size() (which is 4)
--------------------------------
Process exited after 1.197 seconds with return value 3
请按任意键继续. . .
CPP#include<bits/stdc++.h>
using namespace std;
struct abc{
string s;
int f, l;
}a[21];
bool r;
int n, ans;
string b, c, d;
int qwe(string aa, string bb, int l, int o){
for(int i = 1; i < o; i++){
b = bb.substr(0, i);
d = aa.substr(l - i, i);
if (int (d.find(b)) != -1){
b = bb.substr(i, o - i);
// cout << b << endl;
return 1;
}
}
}
int dfs(bool f){
if (f){
int x = c.size();
ans = max(ans, x);
return 0;
}
for(int i = 0; i < n; i++){
if (qwe(c, a[i].s, c.size(), a[i].l) == 1 && a[i].f < 2){
c = c + b;
a[i].f++;
dfs(0);
c.substr(0, c.size() - b.size());
}
}
dfs(1);
}
int main(){
cin >> n;
for(int i = 0; i < n; i++){
cin >> a[i].s;
a[i].l = a[i].s.size();
}
// c = "aaaaa0sasasede";
// string z = "asasede0aaaaaa";//aaaaa0sasasede0aaaaaa
// qwe(c, z, 14, 14);
// cout << c + b;
for(int i = 0; i < n; i++){
r = 1;
c.erase(0);
c = a[i].s;
a[i].f++;
dfs(0);
}
cout << ans;
}
这是什么报错
回复
共 4 条回复,欢迎继续交流。
正在加载回复...