제출 #122740

#제출 시각아이디문제언어결과실행 시간메모리
122740popovicirobert새로운 문제 (POI13_mor)C++14
100 / 100
2598 ms117768 KiB
#include <bits/stdc++.h> #define lsb(x) (x & (-x)) #define ll long long #define ull unsigned long long // 217 // 44 /* const int MOD = ; inline void mod(int &x) { if(x >= MOD) x -= MOD; } inline void add(int &x, int y) { x += y; mod(x); } inline void sub(int &x, int y) { x += MOD - y; mod(x); } inline void mul(int &x, int y) { x = (1LL * x * y) % MOD; } */ using namespace std; const int MAXN = 5000; vector <int> g[MAXN + 1]; short dp[MAXN + 1][MAXN + 1][2]; int main() { //ifstream cin("A.in"); //ofstream cout("A.out"); int i, j, n, m, k; ios::sync_with_stdio(false); cin.tie(0), cout.tie(0); cin >> n >> m >> k; for(i = 1; i <= m; i++) { int x, y; cin >> x >> y; g[x].push_back(y); g[y].push_back(x); } queue < pair <int, int> > Q; for(i = 1; i <= n; i++) { for(j = 1; j <= n; j++) { dp[i][j][0] = dp[i][j][1] = -1; } Q.push({i, 0}); dp[i][i][0] = 0; while(Q.size()) { auto cur = Q.front(); Q.pop(); for(auto it : g[cur.first]) { if(dp[i][it][cur.second ^ 1] == -1) { dp[i][it][cur.second ^ 1] = dp[i][cur.first][cur.second] + 1; Q.push({it, cur.second ^ 1}); } } } } while(k--) { int x, y, d; cin >> x >> y >> d; if(dp[x][y][d & 1] != -1 && ((dp[x][y][d & 1] < d && g[y].size()) || dp[x][y][d & 1] == d)) { cout << "TAK\n"; } else { cout << "NIE\n"; } } //cin.close(); //cout.close(); return 0; }
#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...