답안 #447910

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
447910 2021-07-28T06:57:14 Z idas Toll (BOI17_toll) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i = (begin); i < (end); i++)
#define FAST_IO ios_base::sync_with_stdio(0); cin.tie(nullptr); cout.tie(nullptr)
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define SZ(x) ((int)((x).size()))
#define LE(vec) vec[vec.size()-1]
#define TSTS int t; cin >> t; while(t--)solve()

const int INF = 1e9;
const long long LINF = 1e18;
const long double PI = asin(1)*2;
const int MOD = 1e9+7;

using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef map<int, int> mii;
typedef long long ll;
typedef long double ld;

void setIO()
{
    FAST_IO;
}

void setIO (string s) {
    setIO();
 	freopen((s+".in").c_str(),"r",stdin);
 	freopen((s+".out").c_str(),"w",stdout);
}

const int N=1e9+10;

int k, n, m, o, ans[N];
vector<pii> ad[N];
vi que[N];

void dfs(int u, int tot, vi ar)
{
    int in=0;
    vi nw;
    set<int> tmp;
    FOR(i, 0, (int)que[u].size())
    {
        int x=que[u][i], y=-1;
        tmp.insert(x);
        while(in<(int)ar.size() && ar[in]<x){
            tmp.insert(ar[in]);
            in++;
        }
        if(in<(int)ar.size()) y=ar[in];

        if(x==y){
            ans[x]=min(ans[x], tot);
        }
    }
    while(in<(int)ar.size()){
        tmp.insert(ar[in]);
        in++;
    }

    for(auto x : tmp){
        nw.PB(x);
    }

    for(auto [x, w]: ad[u]){
        dfs(x, tot+w, nw);
    }
}

int main()
{
    setIO();
    cin >> k >> n >> m >> o;
    FOR(i, 0, m)
    {
        int a, b, c;
        cin >> a >> b >> c;
        ad[a].PB({b, c});
    }

    set<int> st;
    FOR(i, 0, o)
    {
        int a, b;
        cin >> a >> b;
        que[a].PB(i+1);
        que[b].PB(i+1);
        st.insert(a);
    }

    FOR(i, 0, n) sort(que[i].begin(), que[i].end());
    fill(ans, ans+o+1, INF);

    for(auto it : st){
        dfs(it, 0, {0});
    }

    FOR(i, 1, o+1)
    {
        cout << (ans[i]==INF?-1:ans[i]) << " ";
    }
}

Compilation message

toll.cpp: In function 'void setIO(std::string)':
toll.cpp:31:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   31 |   freopen((s+".in").c_str(),"r",stdin);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
toll.cpp:32:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   32 |   freopen((s+".out").c_str(),"w",stdout);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/tmp/ccuOxY5m.o: in function `__tcf_0':
toll.cpp:(.text+0x12): relocation truncated to fit: R_X86_64_PC32 against symbol `ad' defined in .bss section in /tmp/ccuOxY5m.o
/tmp/ccuOxY5m.o: in function `setIO()':
toll.cpp:(.text+0x6c2): 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)
toll.cpp:(.text+0x6cd): relocation truncated to fit: R_X86_64_PC32 against symbol `std::cout' defined in .bss._ZSt4cout section in /usr/lib/gcc/x86_64-linux-gnu/10/libstdc++.a(globals_io.o)
/tmp/ccuOxY5m.o: in function `setIO(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)':
toll.cpp:(.text+0x728): 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)
toll.cpp:(.text+0x736): relocation truncated to fit: R_X86_64_PC32 against symbol `std::cout' defined in .bss._ZSt4cout section in /usr/lib/gcc/x86_64-linux-gnu/10/libstdc++.a(globals_io.o)
/tmp/ccuOxY5m.o: in function `dfs(int, int, std::vector<int, std::allocator<int> >)':
toll.cpp:(.text+0xaeb): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/ccuOxY5m.o
toll.cpp:(.text+0xc9c): relocation truncated to fit: R_X86_64_PC32 against symbol `ad' defined in .bss section in /tmp/ccuOxY5m.o
/tmp/ccuOxY5m.o: in function `main':
toll.cpp:(.text.startup+0x2c): relocation truncated to fit: R_X86_64_PC32 against symbol `k' defined in .bss section in /tmp/ccuOxY5m.o
toll.cpp:(.text.startup+0x33): 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)
toll.cpp:(.text.startup+0x3a): 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)
toll.cpp:(.text.startup+0x45): 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