QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#627675#5119. Perfect Worddaoqi#Compile Error//C++171.0kb2024-10-10 16:43:362024-10-10 16:43:36

Judging History

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

  • [2024-10-10 16:43:36]
  • 评测
  • [2024-10-10 16:43:36]
  • 提交

answer

#include<bits/stdc++.h>

using i64 = long long;

void DAOQI() {
    int n;
    std::cin >> n;
    std::vector<std::string> str;
    std::set<std::string> se;
    for (int i = 1; i <= n; i++) {
        std::string s;
        std::cin >> s;
        str.push_back(s);
        se.insert(s);
    }
    std::sort(str.begin(), str.end(), [&](auto &x, auto &y) {
        return x.size() > y.size();
    });

    int ans = 0;
    for (auto &s: str) {
        bool ok = true;
        for (int i = 0; i < s.size(); i++) {
            for (int j = i; j < s.size(); j++) {
                if (se.contains(s.substr(i, j - i + 1))) continue;
                else {
                    ok = false;
                    break;
                }
            }
        }
        if (ok) {
            std::cout << s.size() << "\n";
            return;
        }
    }
}

signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int T = 1;
    //std::cin >> T;
    while (T--) DAOQI();
    return 0;
}

Details

answer.code: In function ‘void DAOQI()’:
answer.code:25:24: error: ‘class std::set<std::__cxx11::basic_string<char> >’ has no member named ‘contains’
   25 |                 if (se.contains(s.substr(i, j - i + 1))) continue;
      |                        ^~~~~~~~