Submission #515881

#TimeUsernameProblemLanguageResultExecution timeMemory
515881ac2huTales of seafaring (POI13_mor)C++14
0 / 100
976 ms117780 KiB
#include <bits/stdc++.h> using namespace std; void setIO(string name) { #ifdef DEBUG #else ios_base::sync_with_stdio(0); cin.tie(0); freopen((name+".in").c_str(),"r",stdin); freopen((name+".out").c_str(),"w",stdout); #endif } signed main(){ iostream::sync_with_stdio(false); cin.tie(nullptr);cout.tie(nullptr); int n,m,k;cin >> n >> m >> k; vector<int> adj[n]; for(int i = 0;i<m;i++){ int a,b;cin >> a >> b; a--;b--; adj[a].push_back(b); adj[b].push_back(a); } vector<vector<int>> dist(n,vector<int>(n,1e9 + 10)); for(int i = 0;i<n;i++){ queue<int> q; dist[i][i] = 0; q.push(i); while(!q.empty()){ int x = q.front(); q.pop(); for(auto e : adj[x]){ if(dist[i][e] > dist[i][x] + 1){ dist[i][e] = dist[i][x] + 1; q.push(e); } } } } // for(int i = 0;i<n;i++){ // for(int j =0 ;j<n;j++) // cout << dist[i][j] << " "; // cout << "\n"; // } for(int _ = 0;_<k;_++){ int a,b,d;cin >> a >> b >> d; a--;b--; if(dist[a][b] <= d) cout << "TAK\n"; else cout << "NIE\n"; } }

Compilation message (stderr)

mor.cpp: In function 'void setIO(std::string)':
mor.cpp:7:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    7 |  freopen((name+".in").c_str(),"r",stdin);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
mor.cpp:8:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 |  freopen((name+".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...
#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...