uva 10887

来源:互联网 发布:电线传输网络信号原理 编辑:程序博客网 时间:2024/05/01 07:25
题意:用set去重水过
#include <iostream>#include <cstring>#include <cstdio>#include <set>using namespace std;char str1[1500][20];char str2[1500][20];int main(){    int cas = 1;    set<string>s1;    int t;    scanf("%d",&t);    while (t--)    {        int n,m;        scanf("%d%d",&n,&m);        getchar();        for (int i = 0; i < n; i++)            gets(str1[i]);                for (int i = 0; i < m; i++)            gets(str2[i]);        for (int i = 0; i < n; i++)            for (int j = 0; j < m; j++)            {                char temp[30];                strcpy(temp,str1[i]);                strcat(temp,str2[j]);                s1.insert(temp);            }        printf("Case %d: %d\n",cas++,s1.size());        s1.clear();    }    return 0;}