Submission #447923

#TimeUsernameProblemLanguageResultExecution timeMemory
447923idasToll (BOI17_toll)C++17
0 / 100
3079 ms2124 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=1e4+10; int k, n, m, o, ans[N]; vector<pii> ad[N]; set<int> que[N]; void dfs(int u, int tot, set<int> ar) { for(auto it : que[u]){ if(ar.count(it)){ ans[it]=min(ans[it], tot); } else{ ar.insert(it); } } for(auto [x, w]: ad[u]){ dfs(x, tot+w, ar); } } 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].insert(i+1); que[b].insert(i+1); st.insert(a); } fill(ans, ans+o+1, INF); for(auto it : st){ set<int> mt; dfs(it, 0, mt); } FOR(i, 1, o+1) { cout << (ans[i]==INF?-1:ans[i]) << "\n"; } }

Compilation message (stderr)

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);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...