답안 #722761

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
722761 2023-04-12T19:53:59 Z vjudge1 Mostovi (COI14_mostovi) C++14
30 / 100
4 ms 340 KB
#include <bits/stdc++.h>

using namespace std;
int n;
bool visited[10002];
bool zabraneto[10002];
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 Correct 4 ms 340 KB Output is correct
3 Correct 3 ms 340 KB Output is correct
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 1 ms 304 KB Execution killed with signal 11
7 Runtime error 1 ms 340 KB Execution killed with signal 11
8 Runtime error 1 ms 340 KB Execution killed with signal 11
9 Runtime error 1 ms 340 KB Execution killed with signal 11
10 Runtime error 1 ms 340 KB Execution killed with signal 11