QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#768748#5119. Perfect WordfosovWA 1ms4000kbC++141.0kb2024-11-21 14:12:492024-11-21 14:12:50

Judging History

你现在查看的是最新测评结果

  • [2024-11-21 14:12:50]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:4000kb
  • [2024-11-21 14:12:49]
  • 提交

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'