QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#126619 | #793. Palindromic Partitions | pbeufiboppeitjxmfla# | 60 | 12ms | 3796kb | C++20 | 1.2kb | 2023-07-18 19:32:56 | 2024-07-04 00:45:01 |
Judging History
answer
using namespace std;
#include <bits/stdc++.h>
#define i32 int
#define i64 long long
#define u32 unsigned int
#define u64 unsigned long long
#define f32 float
#define f64 double
#define vec vector
#define F0R(i, e) for(i32 i = 0; i<e; i++)
#define FOR(i, s, e) for(i32 i = s; i<e; i++)
#define F0Rd(i, e) for(i32 i = e-1; i>=0; i--)
#define FORd(i, s, e) for(i32 i = e-1; i>=s; i--)
#define TRAV(v, g) for(auto v: g)
const i32 INF_32 = INT32_MAX/3;
const i64 INF_64 = INT64_MAX/3;
void solve() {
string s;
cin >> s;
i32 n = s.size();
i32 ans = 0;
i32 cur = 0;
F0R(i, n/2) {
i32 equal = true;
FOR(j, cur, i+1) {
i32 oj = n-cur-1-(i-cur)+j-cur;
if(s[j] != s[oj]) {
equal = false;
break;
}
}
if(equal) {
cur = i+1;
ans += 2;
}
}
if(cur<(n+1)/2) {
ans += 1;
}
cout << ans << endl;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
i32 t = 1;
cin >> t;
while(t--) {
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 15
Accepted
Test #1:
score: 15
Accepted
time: 0ms
memory: 3796kb
input:
10 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaabaaaaaaaaaaaaaab aaaaaaaaaaaaabxaaaaaaaaaaaaab baaaaaaaaaaaaaabaaaaaaaaaaaaaa aabbaabbaabbaaaaaaaabbaabbaabb ababababababababababababababab abcabcabcabcabcabcabcabcabcabc abcabcabcabcabccbacbacbacbacba qntshryhcojkqnlmqeob...
output:
30 29 2 3 2 12 15 10 30 3
result:
ok 10 lines
Test #2:
score: 0
Accepted
time: 0ms
memory: 3512kb
input:
10 aaabbbbaabbbbbbbaaaaabbb aaaababbbaabbabbbaaaaababbb aaabbbbaaaaaaaabbbba aaaaaaabbbbbbbaaaaaaabbbbbbb babbababbabbababbabab abbabaabbaababba bonobo palindrome deemed level
output:
10 5 10 2 17 16 3 1 5 5
result:
ok 10 lines
Test #3:
score: 0
Accepted
time: 0ms
memory: 3768kb
input:
5 abba aabaab x aa ab
output:
4 2 1 2 1
result:
ok 5 lines
Test #4:
score: 0
Accepted
time: 0ms
memory: 3608kb
input:
10 aabbaabbaabbaaaaaaaabbaabbaabb aabbaabbaabbaaaaabbaabbaabb aabbaabbaabbaaaaabbaabbaabb aabbaabbaabbaaaaaaaabbaabbaabb aabbaabbaabbaaaaaaaabbaabbaabb aabbaabbaabbaaaaabbaabbaabb aabbaabbaabbaaaaaaaabbaabbaabb aabbaabbaabbaaaaaabbaabbaabb aabbaabbaabbaaaaaaabbaabbaabb aabbaabbaabbaaaaaaabbaabbaabb
output:
12 9 9 12 12 9 12 10 11 11
result:
ok 10 lines
Test #5:
score: 0
Accepted
time: 0ms
memory: 3604kb
input:
10 abbabaabbaababba abbabaabbaababba abbabaabbaababba abbabaabbaababba abbabaabbaababba abbabaabbaababba abbabaabbaababba abbabaabbaababba abbabaabbaababba abbabaabbaababba
output:
16 16 16 16 16 16 16 16 16 16
result:
ok 10 lines
Subtask #2:
score: 20
Accepted
Dependency #1:
100%
Accepted
Test #6:
score: 20
Accepted
time: 0ms
memory: 3764kb
input:
10 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
output:
300 299 2 3 2 30 150 100 300 11
result:
ok 10 lines
Test #7:
score: 0
Accepted
time: 0ms
memory: 3600kb
input:
6 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbabbbbababaaabbababbbaabbabbabbaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbaaaababbbababbababbaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbabbbbababaaabbababbbaabbabbabbaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb aaaaaaaaaaaaaaaaaaaaaaaaaaaa...
output:
3 9 7 2 177 256
result:
ok 6 lines
Test #8:
score: 0
Accepted
time: 0ms
memory: 3544kb
input:
10 aaaaaaaabbbbbbbbaaaaaaaabbbbbbbbaaaaaaaabbbbbbbbaaaaaaaabbbbbbbbaaaaaaaabbbbbbbbaaaaaaaabbbbbbbbaaaaaaaabbbbbbbbaaaaaaaabbbbbbbbaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbaaaaaaaabbbbbbbbaaaaaaaabbbbbbbbaaaaaaaabbbbbbbbaaaaaaaabbbbbbbbaaaaaaaabbbbbbbbaaaaaaaabbbbbbbbaaaaaaaabbbbbbbb aaaaaaaab...
output:
47 32 31 33 22 46 46 24 34 46
result:
ok 10 lines
Test #9:
score: 0
Accepted
time: 0ms
memory: 3484kb
input:
10 abbabaabbaababbabaababbaabbabaabbaababbaabbabaababbabaabbaababbabaababbaabbabaababbabaabbaababbaabbabaabbaababbabaababbaabbabaabbaababbaabbabaababbabaabbaababbaabbabaabbaababbabaababbaabbabaababbabaabbaababbabaababbaabbabaabbaababbaabbabaababbabaabbaababba abbabaabbaababbabaababbaabbabaabbaababba...
output:
256 256 256 256 256 256 256 256 256 256
result:
ok 10 lines
Subtask #3:
score: 25
Accepted
Dependency #1:
100%
Accepted
Dependency #2:
100%
Accepted
Test #10:
score: 25
Accepted
time: 12ms
memory: 3632kb
input:
10 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
output:
10000 9999 2 3 2 100 5000 3333 9996 495
result:
ok 10 lines
Test #11:
score: 0
Accepted
time: 3ms
memory: 3504kb
input:
6 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
output:
3 9 18 2 5169 4096
result:
ok 6 lines
Test #12:
score: 0
Accepted
time: 1ms
memory: 3628kb
input:
10 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbaaaaaaaaaaaaaaa...
output:
258 282 116 109 287 192 167 251 148 146
result:
ok 10 lines
Test #13:
score: 0
Accepted
time: 0ms
memory: 3564kb
input:
10 abbabaabbaababbabaababbaabbabaabbaababbaabbabaababbabaabbaababbabaababbaabbabaababbabaabbaababbaabbabaabbaababbabaababbaabbabaabbaababbaabbabaababbabaabbaababbaabbabaabbaababbabaababbaabbabaababbabaabbaababbabaababbaabbabaabbaababbaabbabaababbabaabbaababbabaababbaabbabaababbabaabbaababbaabbabaabb...
output:
4096 4096 4096 4096 4096 4096 4096 4096 4096 4096
result:
ok 10 lines
Subtask #4:
score: 0
Time Limit Exceeded
Dependency #1:
100%
Accepted
Dependency #2:
100%
Accepted
Dependency #3:
100%
Accepted
Test #14:
score: 0
Time Limit Exceeded
input:
10 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
output:
1000000 999999