提交翻译
查看原帖
提交翻译
137603
zhiyangfanshotacon楼主2021/11/17 19:49

题意

TT 组数据,每组数据给出 nn 个字符串 SiS_i。对于每组数据,询问 i=1nj=i+1ncnt(strcmp(i,j))\sum_{i=1}^n\sum_{j=i+1}^n cnt(\operatorname{strcmp}(i,j)) 的值。其中 cnt(strcmp(i,j))cnt(\operatorname{strcmp}(i,j)) 表示对 Si,SjS_i,S_j 执行一次 strcmp\operatorname{strcmp} 函数需要的比较次数,strcmp\operatorname{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];
}

注意并不读入 TT,当 n=0n=0 时表示输入停止。对于第 ii 组数据,输出格式为 Case i: Ans,其中 Ans 表示该组数据对应的答案。

数据范围

1T10,1n4×103,1S103,={az,AZ,09}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 表示可能在 SS 中出现的字符集合

### 题意
共 $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

2021/11/17 19:49
加载中...