QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#670540#9430. Left Shifting 2SchoolbagWA 2ms3800kbC++201.3kb2024-10-23 22:11:122024-10-23 22:11:15

Judging History

你现在查看的是最新测评结果

  • [2024-10-23 22:11:15]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3800kb
  • [2024-10-23 22:11:12]
  • 提交

answer

#include <algorithm>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef map<int, int> mii;
typedef unordered_map<int, int> umii;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef vector<int> vi;
typedef vector<vector<int>> vc;
typedef vector<long long> vl;
typedef vector<vector<long long>> vll;
typedef __int128_t int128;
#define rep(x, y, z) for(int x = (y); x <= (z); x++)
#define per(x, y ,z) for(int x = (y); x >= (z); x--)
#define yes cout << "YES\n"
#define no cout << "NO\n"

//#define int long long
//const int N = 1e5 + 5;
//const int mod = 1e9 + 7;
//const ll inf = 1e18;


void solve(){
	string s; cin >> s;
	int lens = s.size();
	s = ' ' + s;
	vi cost;
	rep(i, 1, lens){
		int r = i;
		while(s[i] == s[r] and r <= lens) r++;
		r--;
		int cnt = r - i + 1;
		if(cnt > 1){
			cost.push_back(cnt);
		}
		i = r;
	}
	int ans = 0;
	if(cost.size() == 0){
		cout << ans << '\n';
	}
	else{
		int maxx = *max_element(cost.begin(), cost.end());
		ans += (maxx - 1) / 2;
		int lenc = cost.size();
		rep(i, 0, (int)lenc - 2){
			ans += cost[i] / 2;
		}
		cout << ans << '\n';
	}
}

signed main(){
	std::ios::sync_with_stdio(false);
	std::cin.tie(nullptr);

	int __ = 1; cin >> __;
	while(__--){
		solve();
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3720kb

input:

3
abccbbbbd
abcde
x

output:

2
0
0

result:

ok 3 lines

Test #2:

score: -100
Wrong Answer
time: 2ms
memory: 3800kb

input:

5000
lfpbavjsmppdppkfwnyfmbdhptdswsoulrbhyjh
cfliuqnynejgnxolzbdoztclzbozqomvioszk
eiivcoqoymonrqgrjdtkts
mdcvservaxcbioopfungsgkiftchwlmtbzqgaraovjknsgiegkvdbolmeunvrxrpscnf
ujeqtidwtoikkqtygo
llma
qjfvgwrdhaazejsfgilnpmmhkefndzvyon
kzwwpdpbrudqmwmjscllnnjyoepxophcoopvfepikouinuxx
vftculoorxskpkxoz...

output:

1
0
0
0
0
0
1
4
0
0
1
1
0
1
2
3
0
0
5
6
0
0
5
2
0
1
3
1
0
3
0
1
0
1
1
0
1
4
2
3
1
0
1
5
4
0
3
0
0
1
8
0
0
6
1
2
0
2
0
0
4
1
2
5
3
1
3
2
4
0
2
0
0
0
2
0
3
2
0
4
0
5
5
0
3
0
5
0
0
2
1
0
3
0
1
6
1
2
0
3
3
3
6
2
3
0
3
5
2
3
0
0
3
0
4
6
3
2
1
1
0
0
2
0
2
1
2
3
3
1
2
0
1
1
4
2
1
4
0
1
1
2
0
1
2
0
4
0
2
1
...

result:

wrong answer 13th lines differ - expected: '1', found: '0'