Codeforces Round #354 (Div. 2) 大讨论之术+模拟+分层图+bfs

辣鸡CF 毁我青春

ABC三题都很SB,但需要大讨论之术或者代码写起来容易出错
D题一个一眼题,但写起来神烦,最终还卡了我数组大小
E我没看

最后C题惨遭FST,D后来改了改数组大小就过了,E还是没看

总结:不会写代码了

说白了还是人弱……

跪膜没FST并且rank44并且rating涨了二百多的yzy

掉了六十多rating,竟然这么少 不科学


A

题意:给一个排列,要求必须交换一次使得1和n的位置离得最远。

SB题,要特判一下奇怪的东西……代码写的丑

#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<stack>
using namespace std;

typedef long long LL;
const int SZ = 200010;
const int INF = 1000000010;

int read()
{
    int n = 0;
    char a = getchar();
    bool flag = 0;
    while(a > '9' || a < '0') { if(a == '-') flag = 1; a = getchar(); }
    while(a >= '0' && a <= '9') { n = n * 10 + a - '0'; a = getchar(); }
    if(flag) n = -n;
    return n;
}

int num[SZ];

int main()
{
    int n = read();
    int pos1,pos2;
    for(int i = 1;i <= n;i ++)
    {
        num[i] = read();
        if(num[i] == 1) pos1 = i;
        if(num[i] == n) pos2 = i;
    }
    if(n == 1)
    {
        printf("0"); return 0;
    }
    if(n == 2)
    {
        printf("1"); return 0;
    }
    if(((pos1 == 1 && pos2 == n) || (pos1 == n || pos2 == 1)))
    {
        printf("%d",n - 1);
        return 0;
    }
    printf("%d\n",max(max(abs(n - pos1),abs(1 - pos1)),max(abs(n - pos2),abs(1 - pos2))));
    return 0;
}


B

题意:给n行杯子,构成金字塔形,其中第i行i个杯子。每分钟往顶层的杯子灌一个杯子的量的水,问n排杯子在t时刻后有多少个杯子是满的。

n<=10,0<=t<=10000

我竟然画了半天杨辉三角,最后还是写的模拟……这告诉我们不需要去想一些高端的算法只要能过就行了……

还有t=0的情况……

#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;

typedef long long LL;
const int SZ = 200010;
const int INF = 1000000010;

int read()
{
    int n = 0;
    char a = getchar();
    bool flag = 0;
    
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值