QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#679913 | #9430. Left Shifting 2 | HTensor# | WA | 2ms | 3844kb | C++23 | 1.1kb | 2024-10-26 19:11:32 | 2024-10-26 19:11:33 |
Judging History
answer
#include <bits/stdc++.h>
#define dd(x) cout << #x << "\n"
#define d(x) cout << #x << ": " << x << "\n"
#define SZ(x) ((int)(x).size())
using namespace std;
#define int long long
using pii = pair<int, int>;
using vpii = vector<pii>;
using vi = vector<int>;
using vii = vector<vector<int>>;
using a3 = array<int, 3>;
using ll = long long;
const int inf = 0x3f3f3f3f3f3f3f3fLL;
#define MULTI_TEST
void solve() {
string str; cin >> str; int n = SZ(str); str = " " + str;
vector<int> Q;
if(str[1] == str[n]) {
Q.push_back(1);
}
int cnt = 0;
for(int i = 2; i <= n; i++) {
if(str[i] == str[i - 1]) {
cnt++;
} else {
if(cnt) {
Q.push_back(cnt);
}
}
}
int ans = 0;
for(auto v : Q) {
ans += (v + 1) / 2;
// mx = max(mx, );
}
cout << max(ans - 1, 0LL) << "\n";
}
signed main() {
ios::sync_with_stdio(false); cin.tie(0);
#ifdef MULTI_TEST
int T; cin >> T;
#else
int T = 1;
#endif
while(T--) solve();
return 0;
}
/*
3
abccbbbbd
abcde
x
*/
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3544kb
input:
3 abccbbbbd abcde x
output:
2 0 0
result:
ok 3 lines
Test #2:
score: -100
Wrong Answer
time: 2ms
memory: 3844kb
input:
5000 lfpbavjsmppdppkfwnyfmbdhptdswsoulrbhyjh cfliuqnynejgnxolzbdoztclzbozqomvioszk eiivcoqoymonrqgrjdtkts mdcvservaxcbioopfungsgkiftchwlmtbzqgaraovjknsgiegkvdbolmeunvrxrpscnf ujeqtidwtoikkqtygo llma qjfvgwrdhaazejsfgilnpmmhkefndzvyon kzwwpdpbrudqmwmjscllnnjyoepxophcoopvfepikouinuxx vftculoorxskpkxoz...
output:
26 0 18 52 4 1 21 63 17 0 28 19 6 17 62 94 3 20 87 108 8 2 127 78 4 10 36 46 0 80 2 0 0 0 64 0 17 103 101 128 5 21 0 138 94 11 86 32 0 46 150 0 17 192 62 25 8 32 0 1 114 7 63 44 33 2 90 53 176 0 91 42 47 0 15 6 71 48 19 124 68 100 126 0 108 0 154 2 0 80 64 19 80 0 55 141 15 73 58 41 106 105 43 33 10...
result:
wrong answer 1st lines differ - expected: '1', found: '26'