首页 > 其他分享 >Codeforces Round #281 (Div. 2) A B

Codeforces Round #281 (Div. 2) A B

时间:2023-03-03 13:01:29浏览次数:58  
标签:Vasya int Codeforces number 281 output Div include card

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 output

Vasya 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.

Input

The 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.

Output

For 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.

Input

The 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.

Output

If 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 Note

Sequence 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;
}







标签:Vasya,int,Codeforces,number,281,output,Div,include,card
From: https://blog.51cto.com/u_15990681/6098482

相关文章

  • 基于FPGA的RGB灯WS2812B的控制器设计
    这次设计一个RGB灯的控制器,该控制器具有如下特点:每个灯的颜色可调,亮灭可控可以设置参数来修改RGB的数目 WS2812B的数据时序如下图所示:   (图片来源自网络、......
  • Codeforces Round #850 (Div. 2, based on VK Cup 2022 - Final Round)
    Preface补题,之前由于要准备开学考(其实只是临时抱佛脚罢了),所以好久没写题不过索性学校题目简单,微积分线代C程都满绩了(甚至溢出好多),思政被卡了一分满绩点,而大英不出所料3.7......
  • div水平垂直居中的四种方式
    div水平垂直居中的四种方式让div水平居中的方式,我所知道的就是以下这四种。目录div水平垂直居中的四种方式一、margin二、绝对定位三、子元素绝对定位父元素相对定位四、......
  • Educational Codeforces Round 55 (Rated for Div. 2) G. Petya and Graph 网络流|
    很经典,想记录一下网络流里有一个很典的trick,求最大获利转化成最小损失求最小损失转化成割边求的是max(边权和-边所连接的点权和),考虑把边看成左部点,把点看成右部点刚开......
  • Educational Codeforces Round 144 (Rated for Div. 2)
    链接EducationalCodeforcesRound144(RatedforDiv.2)只会两个题太弱了A题先打表找出一个很长的字符字串然后,用strstr查找找到yes找不到no#include<iostream>......
  • Codeforces 438D The Child and Sequence 势能线段树
    势能线段树|拉线段树题单时发现的这道花神游历各国的骚操作至今让我印象深刻,原来有名字所谓势能,大意就是原本你在高空,操作一点下降一点,势能变少一点..当你落地时,修改......
  • CFR-826-Div-3解题报告
    F.Multi-ColoredSegments题意:数轴上有\(n\)个线段,每个区间有一个颜色\(c\),对于每个线段,求与它颜色不同的线段中与它的最短距离。距离定义为两个线段中的点集最近的......
  • CFR-832-Div-2解题报告
    B.BANBAN题意:给你一个\(n\),生成一个字符串为BAN重复\(n\)遍。每次操作可以选择两个位置进行交换,问至少多少次交换后可以使该串不存在BAN的子序列。输出方案。......
  • CFR-755-Div-2解题报告
    比赛传送门赛时AC三道,补题做出一道。A.MathematicalAddition{%noteinfono-iconProblem%}给你两个正整数\(u,v\),求一对合法的\(x,y\)使得\(\frac{x}{u}+\fra......
  • CFR-844-Div-1-2解题报告
    比赛传送门A.ParallelProjection题意:有一个\(w\timesd\timesh\)的长方体,顶面和底面有两个点,只能走直线且不能穿过长方体,求最短距离。显然曼哈顿距离必须要走。......