Description



Few weeks ago, a famous software company has upgraded its instant messaging software. A ranking system was released for user groups. Each member of a group has a level placed near his nickname. The level shows the degree of activity of a member in the group.

Each member has a score based his behaviors in the group. The level is determined by this method:

Level

Percentage

The number of members in this level

LV1

/

All members whose score is zero

LV2

/

All members who can not reach level 3 or higher but has a positive score

LV3

30%

⌊(The number of members with a positive score) * 30%⌋

LV4

20%

⌊(The number of members with a positive score) * 20%⌋

LV5

7%

⌊(The number of members with a positive score) * 7%⌋

LV6

3%

⌊(The number of members with a positive score) * 3%⌋

  • ⌊x⌋ is the maximum integer which is less than or equal to x.
  • The member with the higher score will get the higher level. If two members have the same score, the earlier one who joined the group will get the higher level. If there is still a tie, the user with smaller ID will get the higher level.

Please write a program to calculate the level for each member in a group.


Input



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

The first line contains an integer N (1 <= N

The next N

  1. The ID of the i-th member Ai (0 <= Ai
  2. The date of the i-th member joined the group, in the format of YYYY/MM/DD. The date will be in the range of [1900/01/01, 2014/04/06].
  3. The score Si (0 <= Si


Output



For each test case, output N


Sample Input



1 5 123456 2011/03/11 308 123457 2011/03/12 308 333333 2012/03/18 4 555555 2014/02/11 0 278999 2011/03/18 308


Sample Output



LV3 LV2 LV2 LV1

LV2


只要理解了题意这就是个水题,简单的说,就是每个等级的名额数是所有有正分数的人乘上各自的百分比,多出来的是lv2,0分的是lv1

#include<cstdio>
#include<algorithm>
#include<vector>
#include<cstring>
#include<iostream>
#include<string>
using namespace std;
const int maxn = 2005;
int n, T, m, lv[7];
struct abc
{
int id, s, lv, x;
string date;
}a[maxn];

bool cmp(const abc& a, const abc& b)
{
if (a.s == b.s&&a.date == b.date) return a.id<b.id;
if (a.s == b.s) return a.date<b.date;
return a.s>b.s;
}

bool cmpl(const abc& a, const abc& b)
{
return a.x<b.x;
}
int main()
{
scanf("%d", &T);
while (T--)
{
scanf("%d", &n);
m = 0;
for (int i = 1; i <= n; i++)
{
cin >> a[i].id >> a[i].date >> a[i].s;
a[i].x = i;
if (a[i].s>0) m++;
}
sort(a + 1, a + n + 1, cmp);
lv[6] = m * 3 / 100;
lv[5] = m * 7 / 100;
lv[4] = m * 20 / 100;
lv[3] = m * 30 / 100;
for (int i = 1; i <= n; i++)
{
if (a[i].s == 0) { a[i].lv = 1; continue; }
if (lv[6]){ lv[6]--; a[i].lv = 6; continue; }
if (lv[5]){ lv[5]--; a[i].lv = 5; continue; }
if (lv[4]){ lv[4]--; a[i].lv = 4; continue; }
if (lv[3]){ lv[3]--; a[i].lv = 3; continue; }
a[i].lv = 2;
}
sort(a + 1, a + n + 1, cmpl);
for (int i = 1; i <= n; i++) printf("LV%d\n", a[i].lv);
}
return 0;
}