#include <bits/stdc++.h>
using namespace std;
int main() {
int N, M, U;
cin >> N >> M >> U;
vector<pair<int, int>> v[N];
int x, y, t;
for (int i = 0; i < M; i++) {
pair<int, int> p;
cin >> x >> y >> t;
x--;
y--;
p.first = y;
p.second = t;
v[x].push_back(p);
p.first = x;
v[y].push_back(p);
}
for (int i = 0; i < U; i++) {
int a, b, maxi;
bool visited[N];
memset(visited, false, sizeof(visited));
cin >> a >> b >> maxi;
a--;
b--;
queue<int> q;
q.push(a);
visited[a] = true;
bool possible = false;
while (!q.empty()) {
if (q.front() == b) {
possible = true;
break;
}
for (pair<int, int> p: v[q.front()]) {
if (visited[p.first]) continue;
if (p.second > maxi) continue;
visited[p.first] = true;
q.push(p.first);
}
q.pop();
}
if (possible) cout << "TAIP\n";
else cout << "NE\n";
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
3 ms |
336 KB |
Output is correct |
3 |
Correct |
4 ms |
592 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Execution timed out |
2079 ms |
1060 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
2 ms |
336 KB |
Output is correct |
4 |
Correct |
6 ms |
476 KB |
Output is correct |
5 |
Correct |
3 ms |
336 KB |
Output is correct |
6 |
Correct |
3 ms |
336 KB |
Output is correct |
7 |
Correct |
3 ms |
336 KB |
Output is correct |
8 |
Correct |
9 ms |
512 KB |
Output is correct |
9 |
Correct |
3 ms |
336 KB |
Output is correct |
10 |
Correct |
18 ms |
592 KB |
Output is correct |
11 |
Correct |
34 ms |
592 KB |
Output is correct |
12 |
Correct |
34 ms |
712 KB |
Output is correct |
13 |
Correct |
4 ms |
592 KB |
Output is correct |
14 |
Correct |
14 ms |
592 KB |
Output is correct |
15 |
Correct |
1 ms |
336 KB |
Output is correct |
16 |
Correct |
1 ms |
336 KB |
Output is correct |
17 |
Correct |
1 ms |
336 KB |
Output is correct |
18 |
Correct |
7 ms |
504 KB |
Output is correct |
19 |
Correct |
420 ms |
1308 KB |
Output is correct |
20 |
Correct |
1 ms |
336 KB |
Output is correct |
21 |
Correct |
1 ms |
336 KB |
Output is correct |
22 |
Correct |
6 ms |
336 KB |
Output is correct |
23 |
Correct |
2 ms |
504 KB |
Output is correct |
24 |
Correct |
322 ms |
848 KB |
Output is correct |
25 |
Correct |
1 ms |
336 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
3 ms |
336 KB |
Output is correct |
3 |
Correct |
4 ms |
592 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Execution timed out |
2079 ms |
1060 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
3 ms |
336 KB |
Output is correct |
3 |
Correct |
4 ms |
592 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Execution timed out |
2079 ms |
1060 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
3 ms |
336 KB |
Output is correct |
3 |
Correct |
4 ms |
592 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Execution timed out |
2079 ms |
1060 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |