답안 #722759

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
722759 2023-04-12T19:52:38 Z vjudge1 Mostovi (COI14_mostovi) C++14
10 / 100
3 ms 468 KB
#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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Runtime error 3 ms 468 KB Execution killed with signal 11
3 Runtime error 3 ms 468 KB Execution killed with signal 11
4 Runtime error 1 ms 340 KB Execution killed with signal 11
5 Runtime error 1 ms 340 KB Execution killed with signal 11
6 Runtime error 2 ms 340 KB Execution killed with signal 11
7 Runtime error 1 ms 468 KB Execution killed with signal 11
8 Runtime error 1 ms 448 KB Execution killed with signal 11
9 Runtime error 1 ms 468 KB Execution killed with signal 11
10 Runtime error 1 ms 416 KB Execution killed with signal 11