QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#645038#8031. Gitignoregjlccc#WA 6ms25520kbC++171.3kb2024-10-16 16:38:482024-10-16 16:38:51

Judging History

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

  • [2024-10-16 16:38:51]
  • 评测
  • 测评结果:WA
  • 用时:6ms
  • 内存:25520kb
  • [2024-10-16 16:38:48]
  • 提交

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'