QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#792880 | #9430. Left Shifting 2 | UESTC_DECAYALI# | WA | 5ms | 3532kb | C++20 | 695b | 2024-11-29 14:51:13 | 2024-11-29 14:51:17 |
Judging History
answer
#include <iostream>
int main() {
int T; std::cin >> T; while(T--) {
std::string s; std::cin >> s;
int ans = 0, t = 0, n = s.size();
for(int l = 0, r; l < n; l = r) {
r = l + 1;
while(r < n && s[r] == s[l]) r++;
ans += (r - l) / 2;
// std::cerr << "[" << l << ", " << r << ")\n";
if(r - l != n && (r - l) % 2 == 0) t = 1;
}
int l, r;
for(l = 0; l + 1 < n && s[l + 1] == s[0]; ++l);
for(r = n; r - 1 >= 0 && s[r - 1] == s[0]; --r);
if((l + 1 + n - r) % 2 == 0) t = 0;
std::cout << std::max(0, ans - t) << char(10);
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3496kb
input:
3 abccbbbbd abcde x
output:
2 0 0
result:
ok 3 lines
Test #2:
score: -100
Wrong Answer
time: 5ms
memory: 3532kb
input:
5000 lfpbavjsmppdppkfwnyfmbdhptdswsoulrbhyjh cfliuqnynejgnxolzbdoztclzbozqomvioszk eiivcoqoymonrqgrjdtkts mdcvservaxcbioopfungsgkiftchwlmtbzqgaraovjknsgiegkvdbolmeunvrxrpscnf ujeqtidwtoikkqtygo llma qjfvgwrdhaazejsfgilnpmmhkefndzvyon kzwwpdpbrudqmwmjscllnnjyoepxophcoopvfepikouinuxx vftculoorxskpkxoz...
output:
1 0 0 0 0 1 1 4 0 0 1 2 1 1 1 3 1 0 5 6 0 0 5 2 0 1 3 2 0 3 0 1 0 1 1 0 2 4 1 3 1 0 2 5 3 0 3 0 0 1 8 1 0 6 1 2 0 1 0 0 4 1 2 4 3 1 3 2 4 1 2 1 0 0 2 0 2 2 0 4 1 5 5 0 3 0 4 1 0 2 1 0 2 0 1 6 1 2 1 3 4 3 5 2 3 0 3 5 1 3 1 0 3 0 4 5 3 2 1 1 0 0 2 0 1 1 3 3 3 1 2 0 1 1 4 3 2 3 1 1 1 2 0 1 2 0 5 0 1 1 ...
result:
wrong answer 6th lines differ - expected: '0', found: '1'