poj2894

简单题

View Code
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
using namespace std;

#define maxn 30
#define maxl 1005

bool f[maxn][maxl];
int n;

void input()
{
memset(f, 0, sizeof(f));
scanf("%d", &n);
for (int i = 0; i < n; i++)
{
char st[4];
int a, b;
scanf("%s", st);
scanf("%d%d", &a, &b);
for (int j = a; j < b; j++)
f[st[0] - 'A'][j] = true;
}
}

void work()
{
for (int i = 0; i < 1000; i++)
{
int x = 0;
for (int j = 0; j < 26; j++)
x += f[j][i];
if (x == 0)
continue;
putchar('A' + x - 1);
}
putchar('\n');
}

int main()
{
//freopen("t.txt", "r", stdin);
int t;
scanf("%d", &t);
while (t--)
{
input();
work();
}
return 0;
}

你可能感兴趣的:(poj)