2021.08.16【普及组】模拟赛C组 总结

2021.08.16【普及组】模拟赛C组总结

写在前面:

今天的考试炸了,头文件错了居然本地没事,QAQ T_T 痛失十分!

明天的考试要认真了!

T1:

题目大意:

在这里插入图片描述

正解:

这道题…暴力即可。

注意: 有负数点,小伙伴们记得特判!

我们不断加点,直到没有舒适的奶牛即可。

来!

code:

#include<bits/stdc++.h>

using namespace std;

const int N = 7001;
const int M = 10000001;

long long a[N][N] , lj = 0; 
long long sum;
long long ans[M];
int fx[5] = {0 , 0 , 1 , 0 , -1};
int fy[5] = {0 , 1 , 0 , -1 , 0};

void bl(int x , int y) {
	long long h = 0 , bx , by;
	for (int i = 1; i <= 4; i ++) {
		if (a[x + fx[i]][y + fy[i]] != 0) {
			h ++;
		}
		else {
			bx = fx[i];
			by = fy[i];
		}
	}
	if (h == 3) {
		lj ++;
		a[x + bx][y + by] = 2;
		bl(x + bx , y + by);
		for (int j = 1; j <= 4; j ++)
				if (a[x + bx + fx[j]][y + by + fy[j]] != 0)
					bl(x + bx + fx[j] , y + by + fy[j]);
	}
	return;
}

int main() {
	long long n , x , y;
	scanf("%lld",&n);
	for (int i = 1; i <= n; i ++) {
		scanf("%lld%lld",&x , &y);
		if (a[x][y] == 2) {
			lj --;
			a[x][y] = 1;
		}
		else {
			a[x][y] = 1;
			bl(x , y);
			for (int j = 1; j <= 4; j ++)
				if (a[x + fx[j]][y + fy[j]] != 0)
					bl(x + fx[j] , y + fy[j]);
		}
		ans[i] = lj;
	}
	for (int i = 1; i <= n; i ++) {
		printf ("%lld\n", ans[i]);
	}
	return 0;
}

过!


T2:

题目大意:

在这里插入图片描述

正解:

我们先把他们每十二年并在一起,并计算他们间隔的距离,将最大的K - 1个间隙用来跳过。

OK ,过!

k - 1的原因因为还要留一次跳回来。(不然,bessie会老死的!)

code:

#include<bits/stdc++.h>
#define rg register

using namespace std;

const int N = 1e5 + 1;

int sum, a[N], v[N], n, k;

inline int read() {
    rg int x = 0, f = 1;
    rg char ch = getchar();
    while (ch < '0' || ch > '9') {
        if (ch == '-')
            f = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9') {
        x = (x << 1) + (x << 3) + (ch ^ 48);
        ch = getchar();
    }
    return x * f;
}

int main() {
	n = read(); k = read(); 
	for (rg int i = 1; i <= n; i ++) {
		a[i] = read();
		if (a[i] % 12 == 0) a[i] /= 12;
		else a[i] = a[i] / 12 + 1;
	}	
	sort(a + 1, a + n + 1); 
	sum = 12 * a[n];
	for (rg int i = 1; i <= n; i ++) v[i] = a[i - 1] - a[i];
	sort(v + 1, v + n + 1);
	-- k;
	for (rg int i = 1; i <= k; i ++){
		if (v[i] == 0) break;
		sum += (v[i] + 1) * 12;
	}
	printf ("%d", sum);
	return 0;
} 
//卡常代码, 请见谅!

过!

祝大家早日AK!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值