답안 #709525

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
709525 2023-03-13T20:39:57 Z TAhmed33 Tales of seafaring (POI13_mor) C++
0 / 100
60 ms 131072 KB
#include <bits/stdc++.h>
using namespace std;
int n, m, k;
vector <int> adj[5001];
int dist[5001][5001][2];
void bfs (int x) {
	queue <pair <int, int>> cur;
	cur.push({x, 0});
	int cnt = 0;
	while (!cur.empty()) {
		int u = cur.size();
		while (u--) {
			auto k = cur.front();
			cur.pop();
			if (k.second == 0) {
				dist[x][k.first][0] = cnt;
				for (auto j : adj[k.first]) {
					if (dist[x][j][1] != -1) continue;
					cur.push({j, 1});
				}
			} else {
				dist[x][k.first][1] = cnt;
				for (auto j : adj[k.first]) {
					if (dist[x][j][0] != -1) continue;
					cur.push({j, 0});
				}
			}
		}
		cnt++;
	}
}	
int main () {
  ios::sync_with_stdio(false);
  cin.tie(0);
	cin >> n >> m >> k;
	memset(dist, -1, sizeof(dist));
	while (m--) {
		int a, b;
		cin >> a >> b;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	for (int i = 1; i <= n; i++) {
		bfs(i);
	}
	while (k--) {
		int a, b, c;
		cin >> a >> b >> c;
		if (dist[b][c][a&1] != -1 && dist[b][c][a&1] <= a) {
			cout << "TAK\n";
		} else {
			cout << "NIE\n";
		}
	}
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 52 ms 131072 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 55 ms 131072 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 52 ms 131072 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 51 ms 131072 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 53 ms 131072 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 54 ms 131072 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 59 ms 131072 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 60 ms 131072 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 54 ms 131072 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 54 ms 131072 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -