QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#768748 | #5119. Perfect Word | fosov | WA | 1ms | 4000kb | C++14 | 1.0kb | 2024-11-21 14:12:49 | 2024-11-21 14:12:50 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define lll __int128
#define INF 0x3f3f3f3f
#define LNF 0x3f3f3f3f3f3f3f3fll
#define MOD 998244353
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ld long double
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define N 5050
int f(ll x) {
if (!x) return 1;
if (x%3) return f(x-1)+1;
return f(x/3)+1;
}
int main() {
#ifdef TEST
freopen("zz.in", "r+", stdin);
#endif
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n; cin >> n;
set<string> s;
vector<string> vs(n);
for (int i = 0; i < n; ++ i) cin >> vs[i];
sort(all(vs), [&](auto& a, auto& b) {
return a.size() < b.size();
});
int res = 0;
s.insert("");
for (auto& t : vs) {
s.insert(t);
int m = t.length() - 1;
if (s.count(t.substr(0, m)) && s.count(t.substr(1, m))) {
res = max(res, (int) t.length());
}
}
cout << res << '\n';
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3636kb
input:
4 a t b ab
output:
2
result:
ok 1 number(s): "2"
Test #2:
score: 0
Accepted
time: 1ms
memory: 4000kb
input:
310 a aa aaa aaaa aaaaa aaaaaa aaaaaaa aaaaaaaa aaaaaaaaa aaaaaaaaaa aaaaaaaaaaa aaaaaaaaaaaa aaaaaaaaaaaaa aaaaaaaaaaaaaa aaaaaaaaaaaaaaa aaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaa...
output:
300
result:
ok 1 number(s): "300"
Test #3:
score: -100
Wrong Answer
time: 0ms
memory: 3932kb
input:
4347 bbaaaab aabab bbaaaaababaaaba aababaaaabbbabababaaaba ababbabbbbbabbbabbab bbbbbbb bbbabbbabbabaab aabbbbabbbbaa aabaaabbbbbabaaababaa aaabababba aaababbaabab abbababbabbab bababaabbbbaaa aaaaaabaaaababaa ababaababba babaababbbababaaab bb abbbaaaababa b ab aaabbbbb abaabaaaaababbbab bbaaabaab b...
output:
12
result:
wrong answer 1st numbers differ - expected: '10', found: '12'