我 叉 我 自 己
查看原帖
我 叉 我 自 己
314991
zhouyuhang楼主2022/1/2 20:06

rt,这是我在赛时拿了 100 pts100\ \texttt{pts} 的代码:

#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;
#define N 1000010
int n, len = 0;
string s[N];
int main(){
    ios::sync_with_stdio(false);
	cin >> n;
	int _max = 0, max_cnt = 0, k = 0;
	for(int i = 1; i <= n; ++i){
		cin >> s[i];
		len += s[i].size();
		int cnt = 1;
		for(int j = 1; j < s[i].size(); ++j) if(s[i][j] != s[i][j - 1]) ++cnt;
		if(cnt == _max && s[i] != s[k]) ++max_cnt;
		else if(_max < cnt){
			_max = cnt;
			max_cnt = 0;
			k = i;
		}
	}
	if(max_cnt) ++_max;
	cout << len - _max << endl;
	return 0;
}

然而这份数据可以叉掉上面的代码:

2
1110
1000

容易发现,方案 1,1,1,2,1,2,2,21,1,1,2,1,2,2,2 的答案为 66,然而跑出来的结果却是 55。请求添加 hack 数据。

2022/1/2 20:06
加载中...