QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#526056 | #5663. Tangle: A DAG for storing transactions | qq11123334 | WA | 0ms | 3612kb | C++20 | 1.5kb | 2024-08-21 10:26:56 | 2024-08-21 10:26:59 |
Judging History
answer
#include <iostream>
#include <vector>
#include <bitset>
using namespace std;
const int MAX_N = 10010;
vector<int> adj[MAX_N]; // Adjacency list to store the graph
int own_weight[MAX_N]; // Stores the own weight of each transaction
bitset<MAX_N> approved_by[MAX_N]; // Bitset to track approvals
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[i] = wx;
adj[y].push_back(i);
adj[z].push_back(i);
}
// Calculate approvals for each transaction
for (int i = 1; i <= n + 1; ++i) {
approved_by[i][i] = 1;
for (int v : adj[i]) {
approved_by[v] |= approved_by[i];
}
}
int confirmed_count = 0;
// Calculate cumulative weights and output confirmed transactions
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;
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3612kb
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'