首页 > 代码库 > Codeforces-475B Strongly Connected City

Codeforces-475B Strongly Connected City

只用判断最外层是不是回路  如果是   则每两个点之间连通


#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#define INF 200000
using namespace std;

int main()
{
    char a[3][22];
    int n,m,i,j;
    scanf("%d%d",&n,&m);
    getchar();
    for(i=1;i<=2;i++)
        scanf("%s",a[i]);
    j=1;
    if(a[1][0]=='<'&&a[2][0]=='^') j=0;
    if(a[1][0]=='>'&&a[2][m-1]=='^') j=0;
    if(a[1][n-1]=='<'&&a[2][0]=='v') j=0;
    if(a[1][n-1]=='>'&&a[2][m-1]=='v') j=0;

    if(j) printf("YES\n");
    else printf("NO\n");
    return 0;
}


Codeforces-475B Strongly Connected City