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