Submission #567283

#TimeUsernameProblemLanguageResultExecution timeMemory
567283shrimbBitaro’s Party (JOI18_bitaro)C++17
Compilation error
0 ms0 KiB
#pragma GCC optimize ("Ofast")
#pragma GCC target ("avx,avx2,fma")

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

template<class x>
using ordered_set = tree<x, null_type,less<x>, rb_tree_tag,tree_order_statistics_node_update>;

#define int long long
#define endl '\n'
#define mod 1000000007
//\
#define mod 1686876991

const int maxn = 200001;
const int sq = 2000;

vector<int> adj[maxn], radj[maxn];

int n, m, q;

pair<int,int> dp[maxn][sq];
int dp2[maxn];
int c[maxn];
bitset<maxn> rem;

signed main () {
    cin.tie(0)->sync_with_stdio(0);
    cin >> n >> m >> q;

    for (int i = 0 ; i < m ; i++) {
        int a, b;
        cin >> a >> b;
        adj[a].push_back(b);
        radj[b].push_back(a);
    }

    for (int i = 1 ; i <= n ; i++) {
        for (int j = 0 ; j < sq ; j++) dp[i][j] = {-1e9,-1};
        dp[i][0] = {0, i};
    }
    for (int i = 1 ; i <= n ; i++) {
        vector<pair<int,int>> v;
        for (auto k : dp[i]) {
            if (k.second == -1) break;
            v.push_back(k);
        }
        for (int j : radj[i]) {
            for (auto k : dp[j]) {
                if (k.second == -1) break;
                v.push_back({k.first + 1, k.second});
            }
        }

        sort(v.begin(), v.end(), greater<pair<int,int>>());
        // cerr << v.size() << endl;
        for (int j = 0 ; j < min(sq, (int)v.size()) ; j++) dp[i][j] = v[j];
        // cerr << "here\n";
    }

    for (int i = 0 ; i < q ; i++) {
        int t, y;
        cin >> t >> y;
        for (int j = 0 ; j < y ; j++) cin >> c[j], rem[c[j]] = 1;
        if (y < sq - 1) {
            for (int j = 0 ; j < sq ; j++) {
                if (dp[t][j].second == -1) break;
                if (!rem[dp[t][j].second]) {
                    cout << dp[t][j].first << endl;
                    goto good;
                }
            }
            cout << -1 << endl;
            good:;
        }
        // else {
        //     for (int j = 1 ; j <= t ; j++) {
        //         dp2[j] = (rem[j] ? -1e9 : 0);
        //         for (int k : radj[j]) dp2[j] = max(dp2[j], dp2[k] + 1);
        //     }
        //     if (dp2[t] < 0) cout << -1 << endl;
        //     else cout << dp2[t] << endl;
        // }
        for (int j = 0 ; j < y ; j++) rem[c[j]] = 0;
    }
}

Compilation message (stderr)

bitaro.cpp:17:1: warning: multi-line comment [-Wcomment]
   17 | //\
      | ^
/tmp/ccFaXcI1.o: in function `__tcf_1':
bitaro.cpp:(.text+0x29): relocation truncated to fit: R_X86_64_PC32 against symbol `radj' defined in .bss section in /tmp/ccFaXcI1.o
/tmp/ccFaXcI1.o: in function `__tcf_0':
bitaro.cpp:(.text+0x69): relocation truncated to fit: R_X86_64_PC32 against symbol `adj' defined in .bss section in /tmp/ccFaXcI1.o
/tmp/ccFaXcI1.o: in function `main':
bitaro.cpp:(.text.startup+0x2e): relocation truncated to fit: R_X86_64_PC32 against symbol `std::cin' defined in .bss._ZSt3cin section in /usr/lib/gcc/x86_64-linux-gnu/10/libstdc++.a(globals_io.o)
bitaro.cpp:(.text.startup+0x3e): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccFaXcI1.o
bitaro.cpp:(.text.startup+0x45): relocation truncated to fit: R_X86_64_PC32 against symbol `std::cin' defined in .bss._ZSt3cin section in /usr/lib/gcc/x86_64-linux-gnu/10/libstdc++.a(globals_io.o)
bitaro.cpp:(.text.startup+0x51): relocation truncated to fit: R_X86_64_PC32 against symbol `m' defined in .bss section in /tmp/ccFaXcI1.o
bitaro.cpp:(.text.startup+0x60): relocation truncated to fit: R_X86_64_PC32 against symbol `q' defined in .bss section in /tmp/ccFaXcI1.o
bitaro.cpp:(.text.startup+0x6f): relocation truncated to fit: R_X86_64_PC32 against symbol `m' defined in .bss section in /tmp/ccFaXcI1.o
bitaro.cpp:(.text.startup+0x8f): relocation truncated to fit: R_X86_64_PC32 against symbol `adj' defined in .bss section in /tmp/ccFaXcI1.o
bitaro.cpp:(.text.startup+0x96): relocation truncated to fit: R_X86_64_PC32 against symbol `radj' defined in .bss section in /tmp/ccFaXcI1.o
bitaro.cpp:(.text.startup+0x9d): additional relocation overflows omitted from the output
/usr/bin/ld: failed to convert GOTPCREL relocation; relink with --no-relax
collect2: error: ld returned 1 exit status