跳到正文

个人记录

河西国庆集训day2

o_0big约 3 分钟
原文
文章信息与版本

文章信息

发布
2026年10月3日
收录
2026年10月5日
更新
2026年11月11日
篇幅
约 3 分钟

版本

  1. v1当前

“T1.小田象棋(chess)”

白棋向上,黑棋向下,注意判断这一列有没有其他的棋子

C++
#include<bits/stdc++.h>
using namespace std;
char a[10][10];
bool f1(int x,int y){
	for(int j = 1;j <= x - 1;j ++){
		if(a[j][y] != '.')return 0;//这里容易写错
	}
	return 1;
}
bool f2(int x,int y){                              
	for(int j = x + 1;j <= 8;j ++){
		if(a[j][y] != '.')return 0;//这里容易写错
	}
	return 1;
}
int main(){
    int W = 8,B = 1;
	for(int i = 1;i <= 8;i ++){
		for(int j = 1;j <= 8;j ++){
			cin >>a[i][j];
		}
	}
	for(int i = 1;i <= 8;i ++){
		for(int j = 1;j <= 8;j ++){
			if(a[i][j] == 'W' && f1(i,j)){
				W = min(W,i);
			}
			if(a[i][j] == 'B' && f2(i,j)){
				B = max(B,i);
			}
		}
	}
    W -= 1;
    B = 8 - B;
	if(W <= B)cout <<'A';
	else cout <<'B';
	return 0;
} 

T2.分数多样性(diverse)

一开始没有看懂题,然后最后知道是求在I时刻有多少种分数,代码就是一个桶排序

C++
#include<bits/stdc++.h>
#define int long long
using namespace std;
int a[200005];
map<int,int>tong;
signed main()
{
    int n,t,cnt = 1;
    cin >>n >>t;
    tong[0] = n;
    for(int i = 1;i <= t;i ++){
        int x,y;
        cin >>x >>y;
        tong[a [x]] --;
        if(tong[a[x]] == 0)cnt --;
        a[x] += y;
        tong[a[x]] ++;
        if(tong[a[x]] == 1)cnt ++;
        cout <<cnt <<'\n';
    }
    return 0;
}

T4.小田坐飞机(airplane)

题目给我们一个坐标,求它是第几秒可以拿到餐,最先想到的是模拟,但是数据范围太大,没法拿满,最后是用的数学规律

C++
#include<bits/stdc++.h>
using namespace std;
map<char,int>m={{'c',6},{'b',5},{'a',4},{'d',3},{'e',2},{'f',1}};
int main(){
    long long n,time = 0;
    char s;
    cin >>n >>s;
    long long pos = (n + 3) / 4;//等几组
    time = (pos - 1) * 16 + m[s];//这组之前完整的时间
    if(n % 2 == 0)time += 7;
    cout <<time;
	return 0;
} 
原文