zoukankan      html  css  js  c++  java
  • Codeforces Round #258 (Div. 2) 小结

    A. Game With Sticks (451A)

    水题一道,事实上无论你选取哪一个交叉点,结果都是行数列数都减一,那如今就是谁先减到行、列有一个为0,那么谁就赢了。因为Akshat先选,因此假设行列中最小的一个为奇数,那么Akshat赢,否则Malvika赢。

    代码:

    #include <iostream>
    #include <cstdio>
    #include <cstring>
    #include <algorithm>
    using namespace std;
    
    int main()
    {
        int a, b;
        while(~scanf("%d%d", &a, &b))
        {
            int minn = a>b?b:a;
            if(minn%2==0)
                printf("Malvika
    ");
            else
                printf("Akshat
    ");
        }
        return 0;
    }

    B. 451B - Sort the Array(451B)

    考察是否能通过一次翻转,将数组变为升序。事实上就是考虑第一个下降的位置,和之后第一个上升的位置,推断边界值大小,细心的话非常easy发现。只是这道题坑点好多,尽管Pretest Pass了,可是,最后WA了,由于在output里面有一个条件没有考虑,就是(start must not be greater than end) 。导致少写一个推断条件,好坑啊。

    代码:

    By dzk_acmer, contest: Codeforces Round #258 (Div. 2), problem: (B) Sort the Array, Accepted, #
     #include <iostream>
    #include <cstdio>
    #include <cstring>
    #include <algorithm>
    using namespace std;
    
    int main()
    {
        int n, a[100010];
        while(~scanf("%d", &n))
        {
            for(int i = 1; i <= n; i++)
                scanf("%d", &a[i]);
            if(n == 1)
            {
                printf("yes
    1 1
    ");
                continue;
            }
            if(n == 2)
            {
                printf("yes
    ");
                if(a[1] < a[2])
                    printf("1 1
    ");
                else
                    printf("1 2
    ");
                continue;
            }
            int st = 1, ed = n, up = 0, down = 0;
            for(int i = 2; i < n; i++)
            {
                if(a[i] > a[i-1] && a[i] > a[i+1])
                {
                    up++;
                    st = i;
                }
                if(a[i] < a[i-1] && a[i] < a[i+1])
                {
                    down++;
                    ed = i;
                }
            }
            a[0] = -100;
            a[n+1] = 1e9+2;
            if(up >= 2 || down >= 2 || st >= ed || a[st] > a[ed+1] || a[ed] < a[st-1])
            {
                printf("no
    ");
                continue;
            }
            printf("yes
    ");
            if(a[st] > a[ed])
                printf("%d %d
    ", st, ed);
            else
                printf("1 1
    ");
        }
        return 0;
    }


  • 相关阅读:
    php命令注入
    mysql事物
    安装php环境
    移除服务器缓存实例
    show user profile synchronization tools
    manual start user profile import
    JSON is undefined. Infopath Form People Picker in SharePoint 2013
    asp.net web 应用站点支持域账户登录
    Load sharepoint envirement by powershell
    sharepoint 2016 download
  • 原文地址:https://www.cnblogs.com/lcchuguo/p/4510190.html
Copyright © 2011-2022 走看看