QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#608162#9349. Exchanging Giftscatwine#WA 1ms3564kbC++141.3kb2024-10-03 19:15:062024-10-03 19:15:06

Judging History

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

  • [2024-10-03 19:15:06]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3564kb
  • [2024-10-03 19:15:06]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

#define int long long
#define endl '\n'

void solve() {
  int n;
  cin >> n;
  vector<vector<int>> a(n + 1);
  vector<unordered_map<int, int>> b(n + 1);
  for (int i = 1; i <= n; i++) {
    int op;
    cin >> op;
    if (op == 1) {
      int m;
      cin >> m;
      a[i].resize(m);
      for (int j = 0; j < m; j++)
        cin >> a[i][j];
    } else {
      int x, y;
      cin >> x >> y;
      if (b[x].size())
        for (auto [num, cnt] : b[x])
          b[i][num] += cnt;
      else
        b[i][x]++;

      if (b[y].size())
        for (auto [num, cnt] : b[y])
          b[i][num] += cnt;
      else
        b[i][y]++;
    }
  }

  unordered_map<int, int> mp;
  if (a[n].size())
    for (auto x : a[n])
      mp[x]++;
  else
    for (auto [num, cnt] : b[n]) {
      for (auto x : a[num]) {
        mp[x] += cnt;
      }
    }

  int mx, total = 0, res = 0;
  for (const auto &[k, v] : mp) {
    mx = max(v, mx);
    total += v;
  }
  if (mx <= total - mx) {
    res = total;
  } else {
    res = 2 * (total - mx);
  }

  cout << res << endl;
}

signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  int T;
  cin >> T;
  while (T--)
    solve();
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3564kb

input:

2
1
1 5 3 3 2 1 3
3
1 3 3 3 2
1 4 2 2 3 3
2 1 2

output:

-8589934580
-8589934576

result:

wrong answer 1st lines differ - expected: '4', found: '-8589934580'