Submission #447909

#TimeUsernameProblemLanguageResultExecution timeMemory
447909idasToll (BOI17_toll)C++11
Compilation error
0 ms0 KiB
#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 (stderr)

toll.cpp: In function 'void dfs(int, int, vi)':
toll.cpp:69:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   69 |     for(auto [x, w]: ad[u]){
      |              ^
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/ccCmNjL8.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/ccCmNjL8.o
/tmp/ccCmNjL8.o: in function `setIO()':
toll.cpp:(.text+0x5e2): 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+0x5ed): 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/ccCmNjL8.o: in function `setIO(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)':
toll.cpp:(.text+0x639): 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+0x650): 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/ccCmNjL8.o: in function `dfs(int, int, std::vector<int, std::allocator<int> >)':
toll.cpp:(.text+0xb25): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/ccCmNjL8.o
toll.cpp:(.text+0xcbc): relocation truncated to fit: R_X86_64_PC32 against symbol `ad' defined in .bss section in /tmp/ccCmNjL8.o
/tmp/ccCmNjL8.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/ccCmNjL8.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