QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#624454 | #9430. Left Shifting 2 | planckconstant# | AC ✓ | 2ms | 3972kb | C++14 | 969b | 2024-10-09 15:53:09 | 2024-10-09 15:53:09 |
Judging History
answer
#include <bits/stdc++.h>
using i64 = long long;
using u64 = unsigned long long;
using u32 = unsigned;
void solve() {
std::string s;
std::cin >> s;
int cnt = 0, ok = false;
while(s.size() and s.back() == s[0]) s.pop_back(), cnt += 1;
int n = s.size();
if(n == 0) {
std::cout << cnt / 2 << '\n';
return;
}
int ans = 0;
for(int i = 0; i < n; i ++ ) {
int j = i + 1;
while(j < n and s[j] == s[i]) j ++;
if(i == 0) {
ans += (j - i + cnt) / 2;
ok |= (j - i + cnt) % 2 == 0;
} else {
ans += (j - i) / 2;
ok |= (j - i) % 2 == 0;
}
i = j - 1;
}
std::cout << ans - ok << '\n';
}
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int t = 1;
std::cin >> t;
while (t--) {
solve();
}
return 0;
}
这程序好像有点Bug,我给组数据试试?
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3848kb
input:
3 abccbbbbd abcde x
output:
2 0 0
result:
ok 3 lines
Test #2:
score: 0
Accepted
time: 2ms
memory: 3668kb
input:
5000 lfpbavjsmppdppkfwnyfmbdhptdswsoulrbhyjh cfliuqnynejgnxolzbdoztclzbozqomvioszk eiivcoqoymonrqgrjdtkts mdcvservaxcbioopfungsgkiftchwlmtbzqgaraovjknsgiegkvdbolmeunvrxrpscnf ujeqtidwtoikkqtygo llma qjfvgwrdhaazejsfgilnpmmhkefndzvyon kzwwpdpbrudqmwmjscllnnjyoepxophcoopvfepikouinuxx vftculoorxskpkxoz...
output:
1 0 0 0 0 0 1 4 0 0 1 1 1 1 1 3 1 0 5 6 0 0 5 2 0 1 3 2 0 3 0 1 0 1 1 0 1 4 1 3 1 0 1 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 3 1 2 1 0 0 2 0 2 2 0 4 0 5 5 0 3 0 4 1 0 2 1 0 2 0 1 6 1 2 1 3 3 3 5 2 3 0 3 5 1 3 0 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 1 3 1 1 1 2 0 1 2 0 4 0 1 1 ...
result:
ok 5000 lines
Test #3:
score: 0
Accepted
time: 0ms
memory: 3828kb
input:
1 cbppzfsncqyzmuwrcvtxsciucxusskcjhaanwhqmyncytwhkubrvcqxgcehdxyewdyvpqjcmrnmlgrytrucexmmfulqbtfctehphmrzkosyvhtvjrromqncbgsjcwhmlqidkycaxyhsrduoxayntuhqubvboseeziwjvrfagsbvtxjjbexnajqapgxydwtztzbbdpoydnjipfizdfpmczgqvdmpvxbqubtygkfpdeonegfzsttirbhzkobbigwneyvtcxndfkljdvbbcfnadtfhgohfzqeidtgyandhnvb...
output:
18631
result:
ok single line: '18631'
Test #4:
score: 0
Accepted
time: 2ms
memory: 3972kb
input:
1 qokalgqjhyijyizyihdsiapbgvzxzevykavqmgqzrpjngciqcljsuplvpaziebmumatzvngwrhgsxrtcoiseihejwpewvosnrgvhoxluliuwixgxylazufebrwgfebazrkghgwbpqavehtnakmzqsetghmzoydwmeqvoplkyqngwrgktylrnaojpkvuwfsjbizedqwhfteyjobrglkhkeoxmxdgyuygawvdjhyakpkjchyxaqthrglcldevrzskdaotkbsbmnstrsxervdvmaylqxnwaecfmdszwedrdom...
output:
0
result:
ok single line: '0'
Test #5:
score: 0
Accepted
time: 2ms
memory: 3716kb
input:
1 bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbyyqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhcccccccccccccccccccccccccccccccccccccccccccccccccccccccccccceeeeeeeeeeeeeeeeeeeeezzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz...
output:
246800
result:
ok single line: '246800'
Test #6:
score: 0
Accepted
time: 2ms
memory: 3884kb
input:
1 yyyyyyyyyyyyyyyyyyyyyyyyhhhhhhhhaaaannnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnhhhhhhhhhhhhhhhhhhhhhhhiiiiiiiieeeeeeeeeesssssssbbbbbbbbbbiiiiiiiwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxaaaaaaaaaaaaaaaadccccckkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkc...
output:
242729
result:
ok single line: '242729'
Extra Test:
score: 0
Extra Test Passed