이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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[5002][5002][3];
vector<short>v[5002];
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(dist[x][a][b%2]!=-1) continue;
dist[x][a][b%2]=b;
for(auto i:v[a]){
q.push({i,b+1});
}
}
}
void solve(){
memset(dist,-1,sizeof(dist));
cin>>n>>m>>k;
for(short i=0;i<m;i++){
short a,b;
cin>>a>>b;
v[a].push_back(b);
v[b].push_back(a);
}
for(short i=1;i<=n;i++) bfs(i);
while(k--){
short a,b;
int c;
cin>>a>>b>>c;
if(a==b&&v[a].size()==0) co "NIE\n";
else if(dist[a][b][c%2]<=c&&dist[a][b][c%2]!=-1) co "TAK\n";
else co "NIE\n";
}
}
int main()
{
suiii
int tt=1;
// cin>>tt;
while(tt--){
solve();
}
return 0;
}
# | 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... |