用户工具

站点工具


2020-2021:teams:manespace:2020_07_18-2020_07_24周报_week11

这是本文档旧的修订版!


2020/07/18–2020/07/24周报(week10)

团队训练

范泽恒

专题

比赛

题目

  • 题意
  • 知识点
  • 题解

恭天祥

专题

比赛

题目

  • 牛客第三次C题:
    1. 题意:给出20个点,这20个点构成了一只手,通过给定的信息判断这只手是左手还是右手
    2. 题解:这个题很新颖,导致很多之前做题的思路都用不上,开始做题时就死磕,想面积,边长…… 都没想到点上 反而浪费了挺多时间,我觉着这个题重再观察,并且读懂题意,我读题时忘记了手掌面积不变,直接导致了队友懵逼了半小时,这个题的具体解决思路也很简单,大拇指外侧的线长6,手掌底部的线长9,小拇指外侧的线长8。判断连续的三根或者两根线是否满足这个规律就行了,由于是浮点数,这题需要控制精度。$eps = 1e-5或更小都行$

刘怀远

专题

比赛

题目

  • cf 656 Problem-D:a-Good String
    1. 题意:多组数据,给定长为n的字符串(n为2的整数次方),输出将其变成“a - good string”最少需要改动的字符数。以ch代指字母,“ch - good string”定义为:(1)长为1且字符为ch;(2)长大于一,且二分后左边字符全为ch,右边为“(ch+1)- good string”;(3)长大于一,且二分后右边字符全为ch,左边为“(ch+1)- good string”。
    2. 题解: 经典二分dfs,维护最小代价即可。

为什么这破题当初能卡那么久

ac代码

ac代码

#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
const int maxn = 2e5 + 5;
const double pi = acos(-1);
const int mod = 998244353;
 
int t, n;
char s[131074];
 
int cal(int l, int r, int c){
	int cnt = 0;
	for(int i = l; i <= r; ++i) if(s[i] != c) ++cnt;
	return cnt;
}
 
int dfs(int l, int r, char c){
	if(l == r) return s[l] != c;
	int res = 3e7;
	int mid = (l + r) >> 1;
	res = min(res, dfs(l, mid, c + 1) + cal(mid + 1, r, c));
	res = min(res, dfs(mid + 1, r, c + 1) + cal(l, mid, c));
	return res;
}
 
int main(){
	scanf("%d", &t);
	while(t--){
		scanf("%d\n", &n);
		scanf("%s", s + 1);
		printf("%d\n", dfs(1, n, 'a'));
	}
} 
2020-2021/teams/manespace/2020_07_18-2020_07_24周报_week11.1595563393.txt.gz · 最后更改: 2020/07/24 12:03 由 intouchables