首页 > 其他 > 详细

Codeforces Round #564 (Div. 2)

时间:2019-06-11 16:39:15      阅读:97      评论:0      收藏:0      [点我收藏+]

这个div2 的AB 还是很简单的,C题思路简单,但是这个模拟不好写啊。

 

A. Nauuo and Votes

这个题目的意思就是说让你判断z是不是会影响x,y进行大小的比较。

这个很简单。

技术分享图片
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <string.h>
#include <queue>
#include  <cmath>
using namespace std;

int main()
{
    int x, y, z;
    scanf("%d%d%d", &x, &y, &z);
    if (z > 0 && abs(x - y) <= z) printf("?\n");
    else if (x > y) printf("+\n");
    else if (y > x) printf("-\n");
    else if (x == y) printf("0\n");
    return 0;
}
A

 

B. Nauuo and Chess

这个B题也很简单,看题就应该会了吧。

技术分享图片
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <queue>
#include  <cmath>
using namespace std;

int main()
{
    int n;
    scanf("%d", &n);
    int m = ((n - 1) % 2 == 0 ? (n - 1) / 2 : ((n - 1) / 2 + 1)) + 1;
    printf("%d\n", m);
    printf("1 1\n");
    n--;
    int r = 1, c = 1;
    while(n--)
    {
        if (r >= m) c++;
        else r++;
        printf("%d %d\n", r, c);
    }
}
B

 

C. Nauuo and Cards

模拟题,挺麻烦的。

技术分享图片
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <queue>
#include  <cmath>
using namespace std;
const int maxn = 2e5 + 10;
int a[maxn],b[maxn];
int num[maxn];
int main()
{
    int n;
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
    for(int i=1;i<=n;i++)
    {
        scanf("%d", &b[i]);
        num[b[i]] = i;
    }
    bool flag = false;
    int tot = b[n];
    while (tot != 1 && num[tot] == num[tot - 1] + 1) tot--;
    if(tot==1)
    {
        //printf("www %d\n", b[n]);
        for(int i=b[n]+1;i<=n;i++)
        {
        //    printf("i=%d %d\n", i, num[i]);
            if (num[i] > i - b[n] - 1) {
                flag = true;
                break;
            }
        }
        if(!flag)
        {
            printf("%d\n", n - b[n]);
            return 0;
        }
    }
    int ans = n, mark = 0;
    int cnt = num[1];
    for(int i=1;i<=n;i++)
    {
        if (num[i] < cnt) cnt++;
        else while (num[i] >= cnt) cnt++;
        //printf("num[%d]=%d cnt=%d\n", i, num[i], cnt);
        if(cnt>=n)
        {
            mark = i;
            break;
        }
    }
    ans += (n - mark) + (cnt - n);
    printf("%d\n", ans);
    return 0;
}
C

 

Codeforces Round #564 (Div. 2)

原文:https://www.cnblogs.com/EchoZQN/p/11004330.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!