답안 #706757

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
706757 2023-03-07T16:49:23 Z aedmhsn Tales of seafaring (POI13_mor) C++17
20 / 100
71 ms 16944 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=1e3+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';
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 8148 KB Output is correct
2 Incorrect 4 ms 8148 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 8148 KB Output is correct
2 Correct 4 ms 8136 KB Output is correct
3 Incorrect 4 ms 8148 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 8244 KB Output is correct
2 Correct 4 ms 8148 KB Output is correct
3 Correct 6 ms 8148 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 8276 KB Output is correct
2 Correct 8 ms 8148 KB Output is correct
3 Correct 27 ms 8148 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 61 ms 8396 KB Output is correct
2 Correct 29 ms 8500 KB Output is correct
3 Incorrect 71 ms 8372 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 12 ms 16584 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 11 ms 16724 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 13 ms 16944 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 13 ms 16508 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 14 ms 16620 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -