QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#379147#8031. Gitignorecomeintocalm#Compile Error//C++172.1kb2024-04-06 16:22:542024-04-06 16:22:55

Judging History

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

  • [2024-04-06 16:22:55]
  • 评测
  • [2024-04-06 16:22:54]
  • 提交

answer

#include <bits/stdc++.h>

int main() {
    // freopen("in", "r", stdin);
    int ttt;
    std::cin >> ttt;
    while (ttt--) {
        int n, m;
        std::cin >> n >> m;
        std::vector<std::map<std::string, int>> ver;
        std::vector<bool> ign;
        ver.emplace_back(std::map<std::string, int>{});
        ign.emplace_back(true);
        int rt = 0;

        auto Insert = [&] (int &p, std::string &t, bool k) -> void {
            if (ver[p].find(t) == ver[p].end()) {
                ver[p].insert({t, (int)ver.size()});
                ver.emplace_back(std::map<std::string, int>{});
                ign.emplace_back(k);
            }
            p = ver[p][t];
            t = "";
        };
        for (int i = 0; i < n; ++i) {
            std::string s, t;
            std::cin >> s;
            int p = rt;
            for (auto &c: s) {
                if (c == '/') {
                    Insert(p, t, true);
                    continue;
                }
                t += c;
            }
            Insert(p, t, true);
        }
        for (int i = 0; i < m; ++i) {
            std::string s, t;
            std::cin >> s;
            int p = rt;
            for (auto &c: s) {
                if (c == '/') {
                    Insert(p, t, false);
                    continue;
                }
                t += c;
            }
            Insert(p, std::move(t), false);
        }

        int ans = 0;
        auto dfs = [&] (auto dfs, const int u) -> bool {
            if (ver[u].empty()) {
                return ign[u];
            }
            bool ignored = true;
            int cnt = 0;
            for (auto &[_, v]: ver[u]) {
                auto child_ign = dfs(dfs, v);
                if (child_ign) {
                    ++cnt;
                }
                ignored = ignored && child_ign;
            }
            //printf("%d %d\n", u, cnt);
            if (!ignored) {
                ans += cnt;
            }
            return ignored;
        } ;
        for (auto &[_, u] : ver[rt]) {
            if (dfs(dfs, u)) {
                ++ans;
            }
        }
        std::cout << ans << '\n';
    }
    return 0;
}

Details

answer.code: In function ‘int main()’:
answer.code:49:19: error: no match for call to ‘(main()::<lambda(int&, std::string&, bool)>) (int&, std::remove_reference<std::__cxx11::basic_string<char>&>::type, bool)’
   49 |             Insert(p, std::move(t), false);
      |             ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
answer.code:16:23: note: candidate: ‘main()::<lambda(int&, std::string&, bool)>’ (near match)
   16 |         auto Insert = [&] (int &p, std::string &t, bool k) -> void {
      |                       ^
answer.code:16:23: note:   conversion of argument 2 would be ill-formed:
answer.code:49:32: error: cannot bind non-const lvalue reference of type ‘std::string&’ {aka ‘std::__cxx11::basic_string<char>&’} to an rvalue of type ‘std::remove_reference<std::__cxx11::basic_string<char>&>::type’ {aka ‘std::__cxx11::basic_string<char>’}
   49 |             Insert(p, std::move(t), false);
      |                       ~~~~~~~~~^~~