• Codeforces Round #187 (Div. 2) A,B


    又是只有AB。。。。
    C题看了1个小时都看不懂。。

    A. Sereja and Bottles
    time limit per test
    2 seconds
    memory limit per test
    256 megabytes
    input
    standard input
    output
    standard output

    Sereja and his friends went to a picnic. The guys had n soda bottles just for it. Sereja forgot the bottle opener as usual, so the guys had to come up with another way to open bottles.

    Sereja knows that the i-th bottle is from brand ai, besides, you can use it to open other bottles of brand bi. You can use one bottle to open multiple other bottles. Sereja can open bottle with opened bottle or closed bottle.

    Knowing this, Sereja wants to find out the number of bottles they've got that they won't be able to open in any way. Help him and find this number.

    Input

    The first line contains integer n (1≤n≤100) — the number of bottles. The next n lines contain the bottles' description. The i-th line contains two integers ai,bi (1≤ai,bi≤1000) — the description of the i-th bottle.

    Output

    In a single line print a single integer — the answer to the problem.

    Sample test(s)
    input
    4
    1 1
    2 2
    3 3
    4 4
    output
    4
    input
    4
    1 2
    2 3
    3 4
    4 1
    output
    0
     

    #include <iostream>
    #include <cstring>

    using namespace std;

    struct soda
    {
        int a;
        int b;
        int isOp;
    }sd[111];

    int main()
    {
        int n;
        cin>>n;
        for(int i=0;i<n;i++)
        {
            cin>>sd.a>>sd.b;
            sd.isOp=0;
        }

        for(int i=0;i<n;i++)
        {
            for(int j=0;j<n;j++)
            {
                if(i==j) continue;
                if(sd[j].isOp)  continue;
                if(sd.b==sd[j].a)
                    sd[j].isOp=1;
            }
        }

        int cur=0;
        for(int i=0;i<n;i++)
            if(sd.isOp==0) cur++;
        cout<<cur<<endl;

        return 0;
    }


    。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。
    B. Sereja and Array
    time limit per test
    1 second
    memory limit per test
    256 megabytes
    input
    standard input
    output
    standard output

    Sereja has got an array, consisting of n integers, a1,a2,...,an. Sereja is an active boy, so he is now going to complete m operations. Each operation will have one of the three forms:

    1. Make vi-th array element equal to xi. In other words, perform the assignment avi=xi.
    2. Increase each array element by yi. In other words, perform n assignments ai=ai+yi (1≤in).
    3. Take a piece of paper and write out the qi-th array element. That is, the element aqi.

    Help Sereja, complete all his operations.

    Input

    The first line contains integers nm (1≤n,m≤105). The second line contains n space-separated integers a1,a2,...,an (1≤ai≤109) — the original array.

    Next m lines describe operations, the i-th line describes the i-th operation. The first number in the i-th line is integer ti (1≤ti≤3) that represents the operation type. If ti=1, then it is followed by two integers vi and xi(1≤vin,1≤xi≤109). If ti=2, then it is followed by integer yi (1≤yi≤104). And if ti=3, then it is followed by integer qi (1≤qin).

    Output

    For each third type operation print value aqi. Print the values in the order, in which the corresponding queries follow in the input.

    Sample test(s)
    input
    10 11
    1 2 3 4 5 6 7 8 9 10
    3 2
    3 9
    2 10
    3 1
    3 10
    1 1 10
    2 10
    2 10
    3 1
    3 10
    3 9
    output
    2
    9
    11
    20
    30
    40
    39


    #include <iostream>

    using namespace std;

    int a[110000];
    int dota=0;
    int n,m;

    int main()
    {
        cin>>n>>m;
        for(int i=1;i<=n;i++)
            cin>>a;
        while(m--)
        {
            int t;
            cin>>t;
            if(t==1)
            {
                int vi,xi;
                cin>>vi>>xi;
                a[vi]=xi-dota;
            }
            else if(t==2)
            {
                int yi;
                cin>>yi;
                dota+=yi;
            }
            else if(t==3)
            {
                int qi;
                cin>>qi;
                cout<<a[qi]+dota<<endl;
            }
        }

        return 0;
    }


  • 相关阅读:
    Mybatis学习01:利用mybatis查询数据库
    SpringBoot_登录注册
    python抓取中科院大学招聘
    centos7设置固定IP
    PIL给图片加水印
    You can ignore those files in your build.gradle
    mysql事件执行时间
    wampserver2.5域名解析错误问题
    Mysql错误消息 语言设置
    js控制select多选
  • 原文地址:https://www.cnblogs.com/CKboss/p/3351032.html
Copyright © 2020-2023  润新知