2014
11-27

# NUDOTA

Welcome to NUDOTA, it’s a game that attracts thousands of people around the campus. In the game, we first get 603 unit of money, and every seconds we get 1unit of money first. When our hero died, we lose 300 unit of money(you will always have non-negative amount of money). Every time you kills an enemy, you will get 200, and if you are the first one to kill enemy among all players, it is called First Blood and you will get an extra 200 unit. When you killed 3 or more enemies consecutively, that means you played very well in the game, and the system will get you an extra money, when you killed 3enemies consecutively, you get extra 50 unit (that means you get 250 unit when you killed the 3rd enemy), and you killed 4enemies consecutively you get extra 100 unit, and you killed 5 enemies consecutively you get extra 150 unit, and so on… Remember the max unit of extra money you get is 400 unit.

Multiple cases.
The input contains N, M, K.(N<1000,M<1000,K<100000)
N means the number of players in team1.
M means the number of players in team2.(lenth of string is less than 1000)
next line containing the N strings indicating the names of N players in team1, seperating by one or more spaces.
next line containing the M strings indicating the names of M players in team2, seperating by one or more spaces.
K means there are K commands and queries.
K lines follow a char that is ‘K’ or ‘Q’.
‘K’ then PLAYER1 kill PLAYER2 in CURRENTTIME.(No two Killing events happens in the same time)
‘Q’ then PLAYER in CURRENTTIME.
input is sorted by CURRENTTIME.( 0<CURRENTTIME<100,000,000 )

Multiple cases.
The input contains N, M, K.(N<1000,M<1000,K<100000)
N means the number of players in team1.
M means the number of players in team2.(lenth of string is less than 1000)
next line containing the N strings indicating the names of N players in team1, seperating by one or more spaces.
next line containing the M strings indicating the names of M players in team2, seperating by one or more spaces.
K means there are K commands and queries.
K lines follow a char that is ‘K’ or ‘Q’.
‘K’ then PLAYER1 kill PLAYER2 in CURRENTTIME.(No two Killing events happens in the same time)
‘Q’ then PLAYER in CURRENTTIME.
input is sorted by CURRENTTIME.( 0<CURRENTTIME<100,000,000 )

1 1 2
a
b
K a b 10
Q a 11

1014

NUDOTA
Time Limit: 2000/1000 MS
(Java/Others)
Memory Limit: 131072/65536 K (Java/Others)
Total Submission(s):
143    Accepted
Submission(s): 38
Problem Description
Welcome to NUDOTA, it’s a game that attracts thousands of people
around the campus. In the game, we first get 603 unit of money, and
every seconds we get 1unit of money first. When our hero died, we
lose 300 unit of money(you will always have non-negative amount of
money). Every time you kills an enemy, you will get 200, and if you
are the first one to kill enemy among all players, it is called
First Blood and you will get an extra 200 unit. When you killed 3
or more enemies consecutively, that means you played very well in
the game, and the system will get you an extra money, when you
killed 3enemies consecutively, you get extra 50 unit (that means
you get 250 unit when you killed the 3rd enemy), and you killed
4enemies consecutively you get extra 100 unit, and you killed 5
enemies consecutively you get extra 150 unit, and so on… Remember
the max unit of extra money you get is 400 unit.
Input
Multiple cases.
The input contains N, M,
K.(N<1000,M<1000,K<100000)
N means the number of players in team1.
M means the number of players in team2.(lenth of string is less
than 1000)
next line containing the N strings indicating the names of N
players in team1, seperating by one or more spaces.
next line containing the M strings indicating the names of M
players in team2, seperating by one or more spaces.
K means there are K commands and queries.
K lines follow a char that is ‘K’ or ‘Q’.
‘K’ then PLAYER1 kill PLAYER2 in CURRENTTIME.(No two Killing events
happens in the same time)
‘Q’ then PLAYER in CURRENTTIME.
input is sorted by CURRENTTIME.(
0<CURRENTTIME<100,000,000 )
Output
If it is a ‘Q’ command you are asked to output the hero’s money in
the CURRENTTIME.
Sample Input
1 1 2
a
b
K a b 10
Q a 11
Sample Output
1014
Author
alpc21
Source
2010 ACM-ICPC Multi-University Training Contest（15）——Host by
NUDT
#######################################解题报告：

########################################Source code:
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
struct man
{
int
team;
char
name[15];
int
po;  //his remaining point
int
lt;
int
kiin;//has killed for how many enemy
}mn[2005];
int main()
{
int i, j, n,
m, k, ct, an, bn;
bool
fir;
//freopen(“data_byhand.txt”, “r”, stdin);
//freopen(“my.txt”, “w”, stdout);
char ch[3],
killer[15], killed[15];
while(scanf(“%d%d%d”, &n, &m,
&k)!=EOF)
{
fir=false;
for(i=0; i<n+m; i++)
{
if(i<n)
mn[i].team=1;
else
mn[i].team=2;
scanf(“%s”, mn[i].name);
mn[i].po=603;mn[i].kiin=0;mn[i].lt=0;
}
getchar();//care!!!!!!!!!!!!!
for(i=0; i<k; i++)
{
scanf(“%s”, ch);
if(ch[0]==’K')
{
scanf(“%s%s%d”, killer, killed, &ct);
getchar();
an=-1; bn=-1;
for(j=0;(!(an>=0&&bn>=0))&&(j<n+m);
j++){
if(strcmp(mn[j].name, killer)==0)
an=j;
else if(strcmp(mn[j].name, killed)==0)
bn=j;
}
if(mn[an].team!=mn[bn].team)
{
mn[an].kiin++;
if(fir==false)
{mn[an].po+=400;fir=true;}
else if(mn[an].kiin>=10)
mn[an].po+=600;
else if(mn[an].kiin<=1)
mn[an].po+=200;
else
mn[an].po+=(200+50*(mn[an].kiin-2));
}
mn[bn].po-=300;
if(mn[bn].po<0)
{
mn[bn].po=0;
mn[bn].lt=ct;
}
mn[bn].kiin=0;
}
else if(ch[0]==’Q')
{
scanf(“%s%d”, killer, &ct);
getchar();
for(j=0; j<n+m; j++)
if(strcmp(mn[j].name, killer)==0)
{
an=j;
break;
}
int re=mn[an].po+ct-mn[an].lt;
printf(“%d\n”, re);
}
}
}
return
0;
}

1. int half(int *array,int len,int key)
{
int l=0,r=len;
while(l<r)
{
int m=(l+r)>>1;
if(key>array )l=m+1;
else if(key<array )r=m;
else return m;
}
return -1;
}
这种就能避免一些Bug
l,m,r
左边是l,m;右边就是m+1,r;