제출 #1013824

#제출 시각아이디문제언어결과실행 시간메모리
1013824Almonther새로운 문제 (POI13_mor)C++98
0 / 100
53 ms59492 KiB
#include <bits/stdc++.h> #define suiii ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); #define ll long long #define co cout<< //#pragma GCC optimize("O3,Ofast,unroll-loops") //#pragma GCC target("avx2,sse3,sse4,avx") using namespace std; //stuff short n,m,k; short dist[5001][5001][2]; bitset<5001>vis[5001][2]; vector<short>v[5001]; void bfs(short x){ queue<pair<short,short>>q; q.push({x,0}); while(q.size()){ auto inp=q.front(); q.pop(); short a,b; a=inp.first; b=inp.second; if(vis[x][a][b%2]||dist[x][a][b%2]!=0) continue; vis[x][a][b%2]=1; dist[x][a][b%2]=b; for(auto i:v[a]){ q.push({i,b+1}); } } } void solve(){ cin>>n>>m>>k; for(int i=0;i<m;i++){ short a,b; cin>>a>>b; v[a].push_back(b); v[b].push_back(a); } for(int i=1;i<=n;i++) bfs(i); while(k--){ short a,b; int c; cin>>a>>b>>c; if(a==b){ if(c%2==1){ if(dist[a][b][c%2]!=0) co "TAK\n"; else co "NIE\n"; } else if(v[a].size()) co "TAK\n"; else co "NIE\n"; } else if(dist[a][b][c%2]<=c&&dist[a][b][c%2]!=0) co "TAK\n"; else co "NIE\n"; } } int main() { suiii int tt=1; // cin>>tt; while(tt--){ solve(); } 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...