QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#526053#5663. Tangle: A DAG for storing transactionsqq11123334WA 0ms3548kbC++201.2kb2024-08-21 10:24:352024-08-21 10:24:36

Judging History

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

  • [2024-08-21 10:24:36]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3548kb
  • [2024-08-21 10:24:35]
  • 提交

answer

#include <iostream>
#include <vector>
#include <bitset>
#include <queue>

using namespace std;

const int MAX_N = 10010;
bitset<MAX_N> approved_by[MAX_N]; // Stores which transactions approve the current transaction
int own_weight[MAX_N];            // Stores the own weight of each transaction
int cumulative_weight[MAX_N];     // Stores the cumulative weight of each transaction

int main() {
    int n, threshold;
    cin >> n >> threshold;

    for (int i = 2; i <= n + 1; ++i) {
        int x, y, z, wx;
        cin >> x >> y >> z >> wx;

        own_weight[x] = wx;
        approved_by[x][x] = 1;
        approved_by[x] |= approved_by[y];
        approved_by[x] |= approved_by[z];
    }

    int confirmed_count = 0;
    for (int i = 2; i <= n + 1; ++i) {
        cumulative_weight[i] = own_weight[i];
        for (int j = approved_by[i]._Find_first(); j < MAX_N; j = approved_by[i]._Find_next(j)) {
            if (j != i) {
                cumulative_weight[i] += own_weight[j];
            }
        }

        if (cumulative_weight[i] >= threshold) {
            cout << i << " " << cumulative_weight[i] << endl;
            confirmed_count++;
        }
    }

    cout << confirmed_count << endl;

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3548kb

input:

6 12
2 0 1 3
3 0 2 2
4 1 2 1
5 2 3 3
6 3 4 4
7 3 5 5

output:

7 13
1

result:

wrong answer 1st lines differ - expected: '2 18', found: '7 13'