# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
515883 | 2022-01-20T04:52:23 Z | ac2hu | Tales of seafaring (POI13_mor) | C++14 | 3000 ms | 99796 KB |
#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 << "NIE\n"; else if((dist[a][b] - d)%2 == 0) cout << "TAK\n"; else { bool flag = false; for(int i = 0;i<n;i++){ int dis = dist[a][i] + dist[i][b]; if(dis <= d && (dis - d)%2 == 0){ flag = true; break; } } if(flag) cout << "TAK\n"; else cout << "NIE\n"; } } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Incorrect | 0 ms | 308 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 204 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 332 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 4 ms | 972 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 15 ms | 1792 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 87 ms | 9396 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1390 ms | 20276 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2741 ms | 67268 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 3097 ms | 99796 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 3101 ms | 99140 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |