# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
722759 | vjudge1 | Mostovi (COI14_mostovi) | C++14 | 3 ms | 468 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
int n;
bool visited[1002];
bool zabraneto[1002];
int kraj;
int most[10000];
bool dfs(int x)
{
visited[x]=true;
if (x==kraj) return true;
bool najde=false;
if (zabraneto[x]==false)
{
if (x<n && visited[x+1]==false) najde=dfs(x+1);
if (najde) return true;
if (x>n+1 && visited[x-1]==false) najde=dfs(x-1);
if (najde) return true;
}
if (most[x]>0 and visited[most[x]]==false) najde=dfs(most[x]);
return najde;
}
int main()
{
cin>>n;
int t;
cin>>t;
while(t--)
{
char a;
int b,c;
cin>>a>>b>>c;
if (a=='A')
{
most[b]=c;
most[c]=b;
}
if(a=='B')
{
if (max(b,c)<=n) zabraneto[min(b,c)]=true;
if (min(b,c)>=n-1) zabraneto[max(b,c)]=true;
}
if(a=='Q')
{
memset(visited,0,sizeof(visited));
kraj=c;
if(dfs(b))
cout<< "DA\n";
else cout<<"NE\n";
}
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |