QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#219650#5663. Tangle: A DAG for storing transactionsshen0628#WA 0ms3644kbC++172.7kb2023-10-19 17:05:522023-10-19 17:05:53

Judging History

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

  • [2023-10-19 17:05:53]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3644kb
  • [2023-10-19 17:05:52]
  • 提交

answer

// #pragma GCC optimize("03,unroll-loops")
// #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <bitset>
#include <set>
#include <unordered_set>
#include <utility>
#include <numeric>
#include <iomanip>
#include <stack>
#include <list>
#include <bitset>
#include <sstream>
#include <random>
#include <stdlib.h>
#include <time.h>
#define ll long long
#define ld long double
#define INF 0x3f3f3f3f
#define MXN 20005
#define cl(x) (x << 1)
#define cr(x) ((x << 1) | 1)
#define SZ(x) (int)x.size()
#define PB push_back
#define lowbit(x) (x & (-x))
#define NO_TAG false
#define P1 75577
#define P2 12721
#define MOD1 998244353
#define MOD2 1000000007

using namespace std;

// mt19937 gen(chrono::steady_clock::now().time_since_epoch().count());

// int rand_int(int lb, int ub) {
//     return uniform_int_distribution<int>(lb, ub)(gen);
// }

int n, val;
vector<vector<int>> edge;
vector<int> vval;
vector<bool> vis;
vector<bitset<MXN>> bs;

void init() {
    edge.clear();
    edge.resize(n + 2);
    vval.clear();
    vval.resize(n + 2, 0);
    vis.clear();
    vis.resize(n + 2, false);
    bs.clear();
    bs.resize(n + 2);
}

void dfs(int x) {
    vis[x] = true;
    bs[x].set(x);
    for(int i:edge[x]) {
        if (vis[i]) {
            continue;
        }
        dfs(i);
        bs[x] |= bs[i];
    }
}

void solve() {
    // 靠邀,我頭很痛。
    // 啊我微積分就退選,你覺得我看起來像會看懂題目的人嗎?
    int res=0;
    cin >> n >> val;
    edge.clear();
    edge.resize(n + 2);
    init();
    for (int i = 0, x, y, z, w; i < n; i++) {
        cin >> x >> y >> z >> w;
        edge[y].push_back(x);
        edge[z].push_back(x);
        vval[x] = w;
    }
    for (int i = 0; i < n + 2; i++) {
        if (!vis[i]) {
            dfs(i);
        }
    }
    for (int i = 2; i < n + 2; i++) {
        int v = 0;
        for (int j = 2; j < n + 2; j++) {
            if (bs[i].test(j)) {
                v += vval[j];
            }
        }
        if (v >= val) {
            cout << i << " " << v << "\n";
            res++;
        }
    }
    cout << res << "\n";
    return ;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    // cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}

/*

5
TATCGATCGAGTTGT
TCCGCGAGCGAGTCTCTCCATT
GTTTCATCATACGAGGCCCCATACGCGCTGG
AGATGGGATCCTTATG
GCCCTTAGGCATGGGATGTCGTTTCTTG

*/

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3640kb

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:

2 18
3 14
2

result:

ok 3 lines

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 3644kb

input:

21 20
2 0 1 2
3 1 0 5
4 1 0 2
5 2 1 1
6 1 3 1
7 5 4 1
8 3 7 5
9 2 4 1
10 4 9 1
11 9 4 5
12 4 8 2
13 3 12 2
14 2 10 5
15 11 12 4
16 3 9 2
17 1 16 4
18 0 7 3
19 11 5 2
20 14 4 5
21 19 5 2
22 18 9 4

output:

2 51
5 26
7 21
9 23
4

result:

wrong answer 2nd lines differ - expected: '3 25', found: '5 26'