This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int INF = 10001;
void solve() {
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;
adj[--a].push_back(--b);
adj[b].push_back(a);
}
short dist[n][n][2];
memset(dist, 0x3f, sizeof(dist));
for(int i = 0; i < n; i++) {
queue<array<int, 2>> q;
q.push({i, 0});
dist[i][i][0] = 0;
while(!q.empty()) {
auto [u, p] = q.front();
q.pop();
for(int v: adj[u]) {
if(dist[i][v][p ^ 1] < INF) continue;
dist[i][v][p ^ 1] = dist[i][u][p] + 1;
q.push({v, p ^ 1});
}
}
}
while(k--) {
int a, b, c;
cin >> a >> b >> c;
--a; --b;
if(dist[a][b][c & 1] > INF || dist[a][b][c & 1] > c) {
cout << "NIE" << '\n';
} else {
cout << "TAK" << '\n';
}
}
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
// freopen("io.out", "w", stdout);
int t = 1;
// cin >> t;
while(t--) solve();
return 0;
}
Compilation message (stderr)
mor.cpp: In function 'void solve()':
mor.cpp:23:18: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
23 | auto [u, p] = q.front();
| ^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |