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!