# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
203294 | MKopchev | 새로운 문제 (POI13_mor) | C++14 | 2182 ms | 27384 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
const int nmax=5e3+42,kmax=1e6+42,inf=1e9+42;
int n,m,k;
vector<int> adj[nmax];
struct query
{
int from,to,dist,id;
};
query inp[kmax];
bool cmp(query a,query b)
{
return a.from<b.from;
}
bool output[kmax];
int dist[nmax][2];
queue< pair<int,bool> > active;
void bfs(int start)
{
for(int i=1;i<=n;i++)
{
dist[i][0]=inf;
dist[i][1]=inf;
}
active.push({start,0});
dist[start][0]=0;
while(active.size())
{
pair<int,bool> current=active.front();
active.pop();
int node=current.first;
bool type=current.second;
//cout<<node<<" "<<type<<" "<<dist[node][type]<<endl;
for(auto k:adj[node])
if(dist[node][type]+1<dist[k][!type])
{
dist[k][!type]=dist[node][type]+1;
active.push({k,!type});
}
}
}
int main()
{
scanf("%i%i%i",&n,&m,&k);
int u,v;
for(int i=1;i<=m;i++)
{
scanf("%i%i",&u,&v);
adj[u].push_back(v);
adj[v].push_back(u);
}
for(int i=1;i<=k;i++)
{
scanf("%i%i%i",&inp[i].from,&inp[i].to,&inp[i].dist);
inp[i].id=i;
}
sort(inp+1,inp+k+1,cmp);
int pointer=1;
for(int i=1;i<=n;i++)
{
bfs(i);
while(inp[pointer].from==i)
{
if(dist[inp[pointer].to][inp[pointer].dist%2]<=inp[pointer].dist)
{
if(dist[inp[pointer].to][inp[pointer].dist%2]==0&&adj[inp[pointer].to].size()==0)output[inp[pointer].id]=0;
else output[inp[pointer].id]=1;
}
pointer++;
}
}
for(int i=1;i<=k;i++)
if(output[i])printf("TAK\n");
else printf("NIE\n");
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | 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... |