# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
515895 | 2022-01-20T05:09:42 Z | ac2hu | Tales of seafaring (POI13_mor) | C++14 | 1502 ms | 131076 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); } int dist[n][n][2]; for(int i = 0;i<n;i++){ for(int j= 0;j<n;j++){ for(int f = 0;f<2;f++) dist[i][j][f] = 1e9 + 10; } } for(int i = 0;i<n;i++){ queue<pair<int,int>> q; dist[i][i][0] = 0; q.push({i,0}); while(!q.empty()){ pair<int,int> x = q.front(); q.pop(); for(auto e : adj[x.first]){ if(dist[i][e][(x.second + 1)%2] > dist[i][x.first][x.second] + 1){ dist[i][e][(x.second + 1)%2] = dist[i][x.first][x.second] + 1; q.push({e,(x.second + 1)%2}); } } } } // 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--; // cout << adj[a].size() << "\n"; if(dist[a][b][d%2] > d || adj[a].size() == 0) cout << "NIE\n"; else { cout << "TAK\n"; } } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Correct | 0 ms | 312 KB | Output is correct |
3 | Correct | 0 ms | 308 KB | Output is correct |
4 | Correct | 250 ms | 19880 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Correct | 0 ms | 204 KB | Output is correct |
3 | Correct | 1 ms | 204 KB | Output is correct |
4 | Correct | 270 ms | 19748 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 332 KB | Output is correct |
2 | Correct | 0 ms | 332 KB | Output is correct |
3 | Correct | 1 ms | 332 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 10 ms | 1604 KB | Output is correct |
2 | Correct | 2 ms | 588 KB | Output is correct |
3 | Correct | 18 ms | 2244 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 30 ms | 3288 KB | Output is correct |
2 | Correct | 10 ms | 5504 KB | Output is correct |
3 | Correct | 48 ms | 5572 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 157 ms | 18228 KB | Output is correct |
2 | Correct | 15 ms | 4756 KB | Output is correct |
3 | Correct | 286 ms | 31860 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 638 ms | 36364 KB | Output is correct |
2 | Correct | 42 ms | 31772 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1502 ms | 130428 KB | Output is correct |
2 | Correct | 101 ms | 32968 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 56 ms | 131076 KB | Execution killed with signal 9 |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 63 ms | 131076 KB | Execution killed with signal 9 |
2 | Halted | 0 ms | 0 KB | - |