QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#645038 | #8031. Gitignore | gjlccc# | WA | 6ms | 25520kb | C++17 | 1.3kb | 2024-10-16 16:38:48 | 2024-10-16 16:38:51 |
Judging History
answer
#include <bits/stdc++.h>
#define _for(i, a, b) for (int i = (a); i <= (b); i++)
#define int long long
#define pb push_back
#define endl "\n"
using namespace std;
const int N = 2e5 + 10;
int n, m;
int c0, c1;
set<int> h[N];
map<string, int> ids[N];
int w[N], dp[N][2];
void dfs(int u) {
dp[u][0] = 0, dp[u][1] = 1;
if (!h[u].size()) {
if (w[u])
dp[u][1] = 1, dp[u][0] = 1e9;
else
dp[u][0] = 0, dp[u][1] = 2;
}
for (auto j : h[u]) {
dfs(j);
dp[u][0] += min(dp[j][0], dp[j][1]);
dp[u][1] += min(dp[j][0] + 1, dp[j][1] - 1);
}
}
void solve() {
cin >> c0 >> c1;
int idx = 1;
ids[1].clear(), h[1].clear(), w[1] = 0;
_for(i, 1, c0 + c1) {
string s;
cin >> s;
int rt = 1;
for (int l = 0, r = 0; l < s.size(); l = r + 1, r = l) {
while (r < s.size() && s[r] != '/') r++;
string t = s.substr(l, r - l);
if (!ids[rt].count(t)) {
ids[rt][t] = ++idx;
h[rt].insert(idx);
h[idx].clear();
ids[idx].clear();
w[idx] = 0;
}
rt = ids[rt][t];
}
w[rt] = i > c0;
}
dfs(1);
cout << dp[1][0] << endl;
}
signed main() {
ios::sync_with_stdio(0);
cin.tie(0);
int T = 1;
cin >> T;
while (T--) {
solve();
}
}
/*
2
3 0
d/t
d/tt
m
3 1
d/t
d/tt
m
d/s
*/
详细
Test #1:
score: 0
Wrong Answer
time: 6ms
memory: 25520kb
input:
2 3 0 data/train data/test model 3 1 data/train data/test model data/sample
output:
0 1
result:
wrong answer 1st numbers differ - expected: '2', found: '0'