AcWing 779. 最长公共字符串后缀
原题链接
困难
作者:
霍可乐
,
2022-07-04 21:06:02
,
所有人可见
,
阅读 161
错误题解,写着写着看错了题目
看成了最后一个字符相等
#include <iostream>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <vector>
#define ios ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define DEBUG printf("Passing [%s] in LINE %d\n",__FUNCTION__,__LINE__)
// 最长公共字符串后缀
using namespace std;
const int N = 2e5 + 10;
int a[N], b[N];
int tot,le[1],rt[1],key[1],value[1];
int main(){
// int n, k;
// scanf("%d %d", &n, &k);
// for(int i = 1;i <= n; ++i) cin >> a[i];
while (1) { // 遇到0 braek
int n; // 接下来的的n 个字符串
cin >> n;
if (n == 0) break;
string str[n + 10];
for (int i = 0; i < n; ++i)
{
cin >> str[i];
}// 读入n 个str
for (int i = 0; i < n; ++i)
{
cout << str[i][str[i].size() - 1]; //后缀总数(下面比对相同的总数是否和读入的n相等)
// cout << str[i].size() << endl;
}// 遍历求每个字符串size 然后用str[][size - 1]得出最后一位,下面接着比较
cout << endl;
}
// int ans = (84 * 2 + 60 * 4 + 79 * 2 + 56 * 1 + 83 * 4 + 85 * 0.5 + 6 * 88 + 4 * 90 + 4 * 82);
// cout << ans / (2 + 4 + 2 + 1 + 4 +0.5 + 6 + 4 + 4);
return 0 ^ 0;
}