QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#378975 | #8031. Gitignore | comeintocalm# | WA | 0ms | 3600kb | C++17 | 2.2kb | 2024-04-06 15:34:36 | 2024-04-06 15:34:37 |
Judging History
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, std::move(t), true);
continue;
}
t += c;
}
Insert(p, std::move(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, std::move(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 << std::max(ans, 1) << '\n';
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3600kb
input:
2 3 0 data/train data/test model 3 1 data/train data/test model data/sample
output:
2 3
result:
ok 2 number(s): "2 3"
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3484kb
input:
5 0 10 szhps/mb/yz szhps/mb/fb/rf/auw szhps/or/ui hy/xkd/k szhps/mb/fb/rf/mu cf/rnd/wjv/xdda szhps/izh gi szhps/mb/fb/xwe hy/xkd/jbq 0 20 gjy/imp/mxuvi/z/ao gjy/s/zft/jxzm gjy/ob/mwvf/la gjy/imp/supe/oxne/p gjy/ob/mwvf/eums/agfb gjy/imp/mxuvi/z/anaj gjy/ob/mwvf/eums/tv gjy/ob/mwvf/eums/x/gg gjy/s/ak...
output:
1 1 1 1 1
result:
wrong answer 1st numbers differ - expected: '0', found: '1'