http://codeforces.com/contest/493
A 第一次结构体开二维数组。。。
A. Vasya and Football time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard outputVasya has started watching football games. He has learned that for some fouls the players receive yellow cards, and for some fouls they receive red cards. A player who receives the second yellow card automatically receives a red card.
Vasya is watching a recorded football match now and makes notes of all the fouls that he would give a card for. Help Vasya determine all the moments in time when players would be given red cards if Vasya were the judge. For each player, Vasya wants to know only thefirst moment of time when he would receive a red card from Vasya.
InputThe first line contains the name of the team playing at home. The second line contains the name of the team playing away. Both lines are not empty. The lengths of both lines do not exceed 20. Each line contains only of large English letters. The names of the teams are distinct.
Next follows number n (1 ≤ n ≤ 90) — the number of fouls.
Each of the following n lines contains information about a foul in the following form:
- first goes number t (1 ≤ t ≤ 90) — the minute when the foul occurs;
- then goes letter "h" or letter "a" — if the letter is "h", then the card was given to a home team player, otherwise the card was given to an away team player;
- then goes the player's number m (1 ≤ m ≤ 99);
- then goes letter "y" or letter "r" — if the letter is "y", that means that the yellow card was given, otherwise the red card was given.
The players from different teams can have the same number. The players within one team have distinct numbers. The fouls go chronologically, no two fouls happened at the same minute.
OutputFor each event when a player received his first red card in a chronological order print a string containing the following information:
- The name of the team to which the player belongs;
- the player's number in his team;
- the minute when he received the card.
If no player received a card, then you do not need to print anything.
It is possible case that the program will not print anything to the output (if there were no red cards).
Sample test(s) input MC CSKA 9 28 a 3 y 62 h 25 y 66 h 42 y 70 h 25 y 77 a 4 y 79 a 25 y 82 h 42 r 89 h 16 y 90 a 13 r output MC 25 70 MC 42 82 CSKA 13 90#include<stdio.h>
#include<iostream>
#include<math.h>
#include<stdlib.h>
#include<ctype.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<sstream>
#include<time.h>
#include<utility>
#include<malloc.h>
#include<stdexcept>
using namespace std;
char zhudui[25];
char kedui[25];
int n;
struct
{
char dui[25];
int num;
int vis;
int p;
}p[2][100];
int T,NUM;
char DUI[2],P[2];
int main ()
{
while (scanf("%s",zhudui)!=EOF)
{
scanf("%s",kedui);
scanf("%d",&n);
for(int i=0;i<=99;i++)
{
p[0][i].p = p[1][i].p = 0;
p[1][i].vis = p[0][i].vis = 0;
}
for(int i=1;i<=n;i++)
{
cin>>T>>DUI>>NUM>>P;
if (DUI[0] == 'h')
{
strcpy (p[0][NUM].dui , zhudui);
if (P[0]=='y')
p[0][NUM].p+=1;
else if (P[0] == 'r')
p[0][NUM].p+=2;
if (p[0][NUM].p>=2 && p[0][NUM].vis == 0)
{
cout<<p[0][NUM].dui<<" "<<NUM<<" "<<T<<endl;
p[0][NUM].vis = 1;
}
}
else if (DUI[0] == 'a')
{
strcpy (p[1][NUM].dui , kedui);
if (P[0]=='y')
p[1][NUM].p+=1;
else if (P[0] == 'r')
p[1][NUM].p+=2;
if (p[1][NUM].p>=2 && p[1][NUM].vis == 0)
{
cout<<p[1][NUM].dui<<" "<<NUM<<" "<<T<<endl;
p[1][NUM].vis = 1;
}
}
}
}
return 0;
}
B 简单题 B. Vasya and Wrestling time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output
Vasya has become interested in wrestling. In wrestling wrestlers use techniques for which they are awarded points by judges. The wrestler who gets the most points wins.
When the numbers of points of both wrestlers are equal, the wrestler whose sequence of points is lexicographically greater, wins.
If the sequences of the awarded points coincide, the wrestler who performed the last technique wins. Your task is to determine which wrestler won.
InputThe first line contains number n — the number of techniques that the wrestlers have used (1 ≤ n ≤ 2·105).
The following n lines contain integer numbers ai (|ai| ≤ 109, ai ≠ 0). If ai is positive, that means that the first wrestler performed the technique that was awarded with ai points. And if ai is negative, that means that the second wrestler performed the technique that was awarded with ( - ai) points.
The techniques are given in chronological order.
OutputIf the first wrestler wins, print string "first", otherwise print "second"
Sample test(s) input 5 1 2 -3 -4 3 output second input 3 -1 -2 3 output first input 2 4 -4 output second NoteSequence x = x1x2... x|x| is lexicographically larger than sequence y = y1y2... y|y|, if either |x| > |y| and x1 = y1, x2 = y2, ... , x|y| = y|y|, or there is such number r (r < |x|, r < |y|), that x1 = y1, x2 = y2, ... , xr = yr and xr + 1 > yr + 1.
We use notation |a| to denote length of sequence a.
#include<stdio.h>
#include<iostream>
#include<math.h>
#include<stdlib.h>
#include<ctype.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<sstream>
#include<time.h>
#include<utility>
#include<malloc.h>
#include<stdexcept>
using namespace std;
long long a[200010];
int main()
{
int n;
while (cin >> n)
{
long long sum = 0;
vector<int> c, d;
for (int i = 0; i < n; i++)
{
cin >> a[i];
sum += a[i];
if (a[i] > 0)
c.push_back(a[i]);
else
d.push_back(-a[i]);
}
if (sum != 0)
{
if (sum > 0)
cout << "first" << endl;
else
cout << "second" << endl;
continue;
}
int l = min(c.size(), d.size());
bool flag = true;
for (int i = 0; i < l; i++)
{
if (c[i] == d[i])
continue;
if (c[i] < d[i]) {
cout << "second" << endl;
}
else {
cout << "first" << endl;
}
flag = false;
break;
}
if (!flag)
continue;
if (c.size() == d.size())
{
if (a[n-1] > 0)
cout << "first" << endl;
else
cout << "second" << endl;
}
else
{
if (c.size() > d.size())
cout << "first" << endl;
else
cout << "second" << endl;
}
}
return 0;
}