共 T 组数据,每组数据给出 n 个字符串 Si。对于每组数据,询问 ∑i=1n∑j=i+1ncnt(strcmp(i,j)) 的值。其中 cnt(strcmp(i,j)) 表示对 Si,Sj 执行一次 strcmp 函数需要的比较次数,strcmp 的实现如下:
int strcmp(char *s, char *t)
{
int i;
for (i=0; s[i]==t[i]; i++)
if (s[i]=='\0')
return 0;
return s[i] - t[i];
}
注意并不读入 T,当 n=0 时表示输入停止。对于第 i 组数据,输出格式为 Case i: Ans
,其中 Ans
表示该组数据对应的答案。
1≤T≤10,1≤n≤4×103,1≤∣S∣≤103,∑={a∼z,A∼Z,0∼9},其中 ∑ 表示可能在 S 中出现的字符集合
### 题意
共 $T$ 组数据,每组数据给出 $n$ 个字符串 $S_i$。对于每组数据,询问 $\sum_{i=1}^n\sum_{j=i+1}^n cnt(\operatorname{strcmp}(i,j))$ 的值。其中 $cnt(\operatorname{strcmp}(i,j))$ 表示对 $S_i,S_j$ 执行一次 $\operatorname{strcmp}$ 函数需要的比较次数,$\operatorname{strcmp}$ 的实现如下:
```cpp
int strcmp(char *s, char *t)
{
int i;
for (i=0; s[i]==t[i]; i++)
if (s[i]=='\0')
return 0;
return s[i] - t[i];
}
\```
注意并不读入 $T$,当 $n=0$ 时表示输入停止。对于第 $i$ 组数据,输出格式为 `Case i: Ans`,其中 `Ans` 表示该组数据对应的答案。
### 数据范围
$1\le T\le 10,1\le n\le4\times10^3,1\le |S|\le10^3,\sum=\{\mathtt{a\sim z},\mathtt{A\sim Z},\mathtt{0\sim 9}\}$,其中 $\sum$ 表示可能在 $S$ 中出现的字符集合
管理员大大注意源码的代码块的结束语句用了 \
转义,不然会把我的源码代码块 给强制结束掉qwq您用的时候注意一下qwq