QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#670570#9430. Left Shifting 2SchoolbagWA 2ms3808kbC++201.2kb2024-10-23 22:22:102024-10-23 22:22:11

Judging History

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

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

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.empty()){
		rep(i, 0, cost.size() - 1){
			if(i == 1){
				ans += (cost[i] - 1) / 2;
			}
			else 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: 1ms
memory: 3808kb

input:

3
abccbbbbd
abcde
x

output:

2
0
0

result:

ok 3 lines

Test #2:

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

input:

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

output:

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

result:

wrong answer 3rd lines differ - expected: '0', found: '1'