Submission #1355769

#TimeUsernameProblemLanguageResultExecution timeMemory
1355769sallySopsug (EGOI23_sopsug)C++20
Compilation error
0 ms0 KiB
#include<iostream>
#include<vector>
#include<set>
#include<cstring>
using namespace std;
const int mx = 3e5+5;
typedef pair<int,int> pii;
int N, M, K;
vector<vector<int>> must(mx);
vector<int> in(mx, 0);
vector<bool> vis(mx, false);
vector<pii> ans;
bool flag = false;
bool ok[mx][mx];
void dfs(int now) {
    vis[now] = 1;
    for(int nxt:must[now]) {
        dfs(nxt);
        ans.push_back({nxt, now});
    }
    for(int nxt = 0; nxt<N; nxt++) {
        if(!ok[now][nxt]) continue;
        if(vis[nxt]) continue;
        ans.push_back({nxt, now});
        dfs(nxt);
    }
}
bool check() {
    for(int i=0; i<N; i++) {
        if(in[i]>1) return false;
        for(int j:must[i]) {
            if(!ok[i][j]) return true;
        }
    }
    return false;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>N>>M>>K;
    memset(ok, true, sizeof(ok));
    vector<bool> v(mx, false);
    for(int i=0; i<M; i++) {
        int a, b;
        cin>>a>>b;
        must[b].push_back(a); // reverse
        in[a]++;
        v[a] = 1;
    }
    for(int i=0; i<K; i++) {
        int a, b;
        cin>>a>>b;
        ok[b][a] = false; // reverse
    }
    if(check()) {
        cout<<"NO";
        return 0;
    }
    int now;
    vis = v;
    for(int i=0; i<N; i++) {
        if(vis[i]) continue;
        now = i;
        dfs(now);
    }
    ans.clear();
    vis = v;
    dfs(now);
    for(int i=0; i<N; i++) {
        if(ans.size()!=N-1) {cout<<"NO"; return 0;}
    }
    for(auto [x, y]:ans) cout<<x<<' '<<y<<'\n';
}

Compilation message (stderr)

/tmp/ccnrWkd3.o: in function `dfs(int)':
Main.cpp:(.text+0xa2): relocation truncated to fit: R_X86_64_PC32 against symbol `vis' defined in .bss section in /tmp/ccnrWkd3.o
Main.cpp:(.text+0xdf): relocation truncated to fit: R_X86_64_PC32 against symbol `must' defined in .bss section in /tmp/ccnrWkd3.o
Main.cpp:(.text+0x116): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/ccnrWkd3.o
Main.cpp:(.text+0x11d): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/ccnrWkd3.o
Main.cpp:(.text+0x13b): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/ccnrWkd3.o
Main.cpp:(.text+0x14a): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/ccnrWkd3.o
Main.cpp:(.text+0x16a): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/ccnrWkd3.o
Main.cpp:(.text+0x17c): relocation truncated to fit: R_X86_64_PC32 against symbol `vis' defined in .bss section in /tmp/ccnrWkd3.o
Main.cpp:(.text+0x19e): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/ccnrWkd3.o
Main.cpp:(.text+0x1a5): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/ccnrWkd3.o
Main.cpp:(.text+0x1c0): additional relocation overflows omitted from the output
/usr/lib/gcc/x86_64-linux-gnu/13/libstdc++.a(ios_init.o): in function `std::ios_base::Init::Init()':
(.text._ZNSt8ios_base4InitC2Ev+0x1f): failed to convert GOTPCREL relocation against '_ZNSt8ios_base4Init11_S_refcountE'; relink with --no-relax
(.text._ZNSt8ios_base4InitC2Ev+0x1ed): failed to convert GOTPCREL relocation against '_ZSt4cout'; relink with --no-relax
(.text._ZNSt8ios_base4InitC2Ev+0x252): failed to convert GOTPCREL relocation against '_ZSt3cin'; relink with --no-relax
(.text._ZNSt8ios_base4InitC2Ev+0x2bc): failed to convert GOTPCREL relocation against '_ZSt4cerr'; relink with --no-relax
(.text._ZNSt8ios_base4InitC2Ev+0x316): failed to convert GOTPCREL relocation against '_ZSt4clog'; relink with --no-relax
(.text._ZNSt8ios_base4InitC2Ev+0x50f): failed to convert GOTPCREL relocation against '_ZSt5wcout'; relink with --no-relax
(.text._ZNSt8ios_base4InitC2Ev+0x57d): failed to convert GOTPCREL relocation against '_ZSt4wcin'; relink with --no-relax
(.text._ZNSt8ios_base4InitC2Ev+0x5f0): failed to convert GOTPCREL relocation against '_ZSt5wcerr'; relink with --no-relax
(.text._ZNSt8ios_base4InitC2Ev+0x654): failed to convert GOTPCREL relocation against '_ZSt5wclog'; relink with --no-relax
/usr/bin/ld: final link failed
collect2: error: ld returned 1 exit status