제출 #315797

#제출 시각아이디문제언어결과실행 시간메모리
315797shrek12357새로운 문제 (POI13_mor)C++14
0 / 100
1 ms512 KiB
#include <iostream> #include <vector> #include <algorithm> #include <string> #include <map> #include <set> #include <climits> #include <cmath> #include <fstream> #include <queue> #include <stack> #include <bitset> using namespace std; #define ll long long //cin.tie(0);ios_base::sync_with_stdio(0); const int MAXN = 10; int main() { int n, m, k; cin >> n >> m >> k; vector<int> adjList[MAXN]; for (int i = 0; i < m; i++) { int a, b; cin >> a >> b; a--; b--; adjList[a].push_back(b); adjList[b].push_back(a); } int paths[MAXN][MAXN][2]; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { paths[i][j][0] = -1; paths[i][j][1] = -1; } paths[i][i][0] = 0; } queue<pair<int, int>> q; for (int i = 0; i < n; i++) { q.push({ i, 0 }); while (q.size() > 0) { int cur = q.front().first; int num = q.front().second; q.pop(); for (auto j : adjList[cur]) { if (paths[i][j][(num + 1) % 2] == -1 || paths[i][j][(num + 1) % 2] > num + 1) { q.push({ j, num + 1 }); paths[i][j][(num + 1) % 2] = num + 1; } } } } for (int i = 0; i < k; i++) { int a, b, c; cin >> a >> b >> c; a--; b--; if (paths[a][b][c%2] == -1 || c < paths[a][b][c % 2] || (paths[a][b][c % 2] == 1 && c != 1)) { cout << "NIE" << endl; } else { cout << "TAK" << endl; } } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...