이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 || (a == b && adj[a].size() == 0)) {
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;
}
컴파일 시 표준 에러 (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... |