Submission #706756

# Submission time Handle Problem Language Result Execution time Memory
706756 2023-03-07T16:48:44 Z aedmhsn Tales of seafaring (POI13_mor) C++17
0 / 100
60 ms 131072 KB
#include <bits/stdc++.h>
using namespace std;
 
 
#define A first
#define B second
#define MP make_pair
#define ms(a, x) memset(a, x, sizeof(a)) 
 
 
#define boost() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef pair<long double, long double> pld;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1);

const int mxN=5e3+5;

vector <vector<int>> adj(mxN);

int dp[mxN][mxN][2];

void bfs(int node){
    queue <int> q;
    q.push(node);
    dp[node][node][0]=0;
    while(!q.empty()){
        int u = q.front();
        q.pop();
        for(auto x:adj[u]){
            if(dp[node][u][0]+1 < dp[node][x][1]){
                dp[node][x][1] = dp[node][u][0]+1;
                q.push(x);
            }
        }
        for(auto x:adj[u]){
            if(dp[node][u][1]+1 < dp[node][x][0]){
                dp[node][x][0] = dp[node][u][1]+1;
                q.push(x);
            }
        }
    }
}

int main(){
    ms(dp, INF);
    int n, m, k;
    cin >> n >> m >> k;
    for(int i=0; i<m; i++){
        int x, y;
        cin >> x >> y;
        adj[x].push_back(y);
        adj[y].push_back(x);
    }
    for(int i=1; i<=n; i++){
        bfs(i);
    }
    while(k--){
        int x, y, d;
        cin >> x >> y >> d;
        cout << (dp[x][y][(d%2)] <= d ? "TAK":"NIE") << '\n';
    }
}
# Verdict Execution time Memory Grader output
1 Runtime error 50 ms 131072 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 60 ms 131072 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 58 ms 131072 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 48 ms 131072 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 56 ms 131072 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 53 ms 131072 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 53 ms 131072 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 52 ms 131072 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 59 ms 131072 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 49 ms 131072 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -