QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#670549 | #9430. Left Shifting 2 | Schoolbag | WA | 2ms | 3616kb | C++20 | 1.4kb | 2024-10-23 22:12:44 | 2024-10-23 22:12:45 |
Judging History
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());
if(maxx == lens){
cout << maxx / 2 << '\n';
return;
}
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: 3616kb
input:
3 abccbbbbd abcde x
output:
2 0 0
result:
ok 3 lines
Test #2:
score: -100
Wrong Answer
time: 2ms
memory: 3528kb
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 1 0 6 1 2 0 2 0 0 4 1 2 5 3 1 3 2 4 1 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'