QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#213631#5119. Perfect Worducup-team1001#WA 0ms3848kbC++20982b2023-10-14 15:14:232023-10-14 15:14:23

Judging History

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

  • [2023-10-14 15:14:23]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3848kb
  • [2023-10-14 15:14:23]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;
int maxn = 1e5;
#define rep(i, a, b) for(int i = (a); i <= (b); ++i)
int n;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n;
    vector<unordered_set<string_view>> v(450);
    rep(i, 1, n) {
        string s;
        cin >> s;
        auto sz = s.size();
        if (sz < 450) {
            v[sz].emplace(s);
        }
    }
    unordered_set<string_view> last(v[1]);
    rep(i, 2, 450 - 1) {
//        cout<<i<<endl;
//        for(auto&&s:last){
//            cout<<s;
//        }
        unordered_set<string_view> now;
        for (auto &&s: v[i]) {
            if (last.contains(string_view(s.begin(), s.end() - 1)) &&
                last.contains(string_view(s.begin() + 1, s.end()))) {
                now.emplace(s);
            }
        }
        if (now.empty()) {
            cout << i - 1;
            return 0;
        }
        last = now;
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3848kb

input:

4
a
t
b
ab

output:

1

result:

wrong answer 1st numbers differ - expected: '2', found: '1'