0
点赞
收藏
分享

微信扫一扫

ZOJ 3603 Draw Something Cheat

小_北_爸 2022-11-10 阅读 74


Have you played Draw Something? It's currently one of the hottest social drawing games on Apple iOS and Android Devices! In this game, you and your friend play in turn. You need to pick a word and draw a picture for this word. Then your friend will be asked what the word is, given the picture you have drawn. The following figure illustrates a typical scenario in guessing the word.

As you see, when guessing a word you will be given the picture and 12 letters. You must pick some of these letters to form a word that matches the picture. Each letter can only be used once. It is a lot of fun if your friend is a talented painter, but unfortunately some drawings from your friend are totally incomprehensible. After several times of becoming mad by the drawings, you find a way to cheat in the game.

In this game, letters not included in the correct answer are randomly generated. If you cannot find the correct answer when guessing, you can write down all the letters and restart the game. Then you would find some of these letters are changed. Of course these changed letters will never appear in the answer. By eliminating these letters you are a step closer to the answer.

So In this problem, you need to write a program to automate the cheating process. Given N

Input

There are multiple test cases. The first line of the input is an integer T

Each test case begins with a positive integer N ≤ 20 indicating the number of times you have entered the game. Then N

Output

For each test case, output the remaining letters in alphabet order after the process described above. One line for each test case.

Sample Input

2
2
ABCDEFGHIJKL
ABCDEFGHIJKL
2
SAWBCVUXDTPN
ZQTLFJYRCGAK

Sample Output

ABCDEFGHIJKL

ACT


简单题

#include<map>
#include<cmath>
#include<queue>
#include<vector>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define ms(x,y) memset(x,y,sizeof(x))
#define rep(i,j,k) for(int i=j;i<=k;i++)
#define per(i,j,k) for(int i=j;i>=k;i--)
#define loop(i,j,k) for (int i=j;i!=-1;i=k[i])
#define inone(x) scanf("%d",&x)
#define intwo(x,y) scanf("%d%d",&x,&y)
#define inthr(x,y,z) scanf("%d%d%d",&x,&y,&z)
typedef long long LL;
const int low(int x) { return x&-x; }
const int INF = 0x7FFFFFFF;
const int mod = 1e9 + 7;
const int N = 1e3 + 10;
int T, n, f[N], g[N];
char s[N];

int main()
{
for (inone(T); T--;)
{
inone(n);
rep(i, 0, 26) f[i] = INF;
rep(i, 1, n)
{
scanf("%s", s);
rep(j, 0, 26) g[j] = 0;
for (int j = 0; s[j]; j++) g[s[j] - 'A']++;
rep(j, 0, 26) f[j] = min(f[j], g[j]);
}
rep(i, 0, 26) rep(j, 1, f[i]) putchar('A' + i);
putchar(10);
}
return 0;
}


举报

相关推荐

0 条评论