【CF475B】Strongly Connected City

题面

分析

这题有几种做法。

  1. Tarjan
  2. BFS
  3. 只考虑外圈是否连通(我的做法)

代码

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#define il inline
#define re register
#define tie0 cin.tie(0),cout.tie(0)
#define fastio ios::sync_with_stdio(false)
using namespace std;
typedef long long ll;

template<typename T>inline void read(T &x){
    T f=1;x=0;char c;
    for(c=getchar();!isdigit(c);c=getchar())if(c=='-')f=-1;
    for(;isdigit(c);c=getchar())x=x*10+(c^48);
    x*=f;
}

int n,m;
char ns[21],we[21];

int main(){
    read(n),read(m);
    cin>>we>>ns;
    --n,--m;
    if(ns[m]=='^'&&we[0]=='>') {puts("NO");exit(0);}
    if(ns[0]=='^'&&we[0]=='<') {puts("NO");exit(0);}
    if(ns[0]=='v'&&we[n]=='<') {puts("NO");exit(0);}
    if(ns[m]=='v'&&we[n]=='>') {puts("NO");exit(0);}
    puts("YES");
    return 0;
}

转载于:https://www.cnblogs.com/hlw1/p/11282794.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值