QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#479337 | #5440. P-P-Palindrome | UESTC_DECAYALI# | TL | 9ms | 7492kb | C++17 | 732b | 2024-07-15 16:30:49 | 2024-07-15 16:30:50 |
Judging History
answer
#include <bits/stdc++.h>
bool is_palin(const std::string& s) {
for(int i = 0, j = s.size() - 1; i < j; ++i, --j)
if(s[i] != s[j]) return false;
return true;
}
int main() {
// freopen("data.in", "r", stdin);
// freopen("data.ans", "w", stdout);
int n; std::cin >> n;
std::vector<std::string> s(n);
for(auto &s: s) std::cin >> s;
std::set<std::string> hkr;
std::set<std::pair<std::string, std::string>> ans;
for(auto s: s) for(int i = 0; i < s.size(); ++i) for(int j = i; j < s.size(); ++j) {
auto sub = s.substr(i, j - i + 1);
if(is_palin(sub)) hkr.insert(sub);
}
for(auto p: hkr) for(auto q: hkr) if(is_palin(p + q)) ans.insert({p, q});
std::cout << ans.size() << char(10);
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3808kb
input:
2 aaaa aaa
output:
16
result:
ok 1 number(s): "16"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3576kb
input:
3 abaaa abbbba bbbaba
output:
28
result:
ok 1 number(s): "28"
Test #3:
score: 0
Accepted
time: 9ms
memory: 7492kb
input:
1 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab
output:
15130
result:
ok 1 number(s): "15130"
Test #4:
score: 0
Accepted
time: 0ms
memory: 3692kb
input:
3 aaaaaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbbbbbbbb bababababababaabababababa
output:
1282
result:
ok 1 number(s): "1282"
Test #5:
score: -100
Time Limit Exceeded
input:
5 ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff...