# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1013890 | vjudge1 | 새로운 문제 (POI13_mor) | C++17 | 431 ms | 131072 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
vector<bool> vis(5006);
vector<ll> v[5006];
ll dis[5006][5006],win[5006];
bool b[5006][5006];
ll n,m;
void bfs(ll i){
queue<pair<ll,ll>> q;
q.push({i,0});
bool vi[5006]={};
dis[i][i]=0;
b[i][i]=1;
vi[i]=1;
while(!q.empty()){
pair<ll,ll> x=q.front();
q.pop();
for(int j=0;j<v[x.first].size();j++){
if(!vi[v[x.first][j]]){
vi[v[x.first][j]]=1;
dis[i][v[x.first][j]]=x.second+1;
b[i][v[x.first][j]]=1;
q.push({v[x.first][j],x.second+1});
}
else{
if(dis[i][v[x.first][j]]%2!=(dis[i][x.first]+1)%2){
win[v[x.first][j]]=(dis[i][x.first]+1)-dis[i][v[x.first][j]];
}
}
}
}
}
int main() {
ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
ll q;
cin>>n>>m>>q;
for(int i=0;i<m;i++){
ll x,y;
cin>>x>>y;x--;y--;
v[x].push_back(y);
v[y].push_back(x);
}
for(int i=0;i<n;i++)bfs(i);
for(int i=0;i<n;i++){
if(win[i]>0){
for(int j=0;j<n;j++){
if(b[i][j]){
if(win[j]==0||win[j]>win[i])win[j]=win[i];
}
}
}
}
while(q--){
ll x,y,d;
cin>>x>>y>>d;
x--;y--;
if(b[x][y]){
if((win[x]!=0)&&win[x]+dis[x][y]<=d){
cout<<"TAK\n";
}
else if(dis[x][y]<=d&&dis[x][y]%2==d%2){
cout<<"TAK\n";
}
else{
cout<<"NIE\n";
}
}
else{
cout<<"NIE\n";
}
}
}
컴파일 시 표준 에러 (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... |