D - Strongly Connected City

本文探讨了在给定的城市网格中,通过设置单向街道实现强连通性的问题,即从任意一点出发都能到达城市的任何其他点。通过输入描述街道方向的字符串,判断所给的街道布局是否满足条件。

D - Strongly Connected City
Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u

Description

Imagine a city with n horizontal streets crossing m vertical streets, forming an (n - 1) × (m - 1) grid. In order to increase the traffic flow, mayor of the city has decided to make each street one way. This means in each horizontal street, the traffic moves only from west to east or only from east to west. Also, traffic moves only from north to south or only from south to north in each vertical street. It is possible to enter a horizontal street from a vertical street, or vice versa, at their intersection.

The mayor has received some street direction patterns. Your task is to check whether it is possible to reach any junction from any other junction in the proposed street direction pattern.

Input

The first line of input contains two integers n and m, (2 ≤ n, m ≤ 20), denoting the number of horizontal streets and the number of vertical streets.

The second line contains a string of length n, made of characters '<' and '>', denoting direction of each horizontal street. If the i-th character is equal to '<', the street is directed from east to west otherwise, the street is directed from west to east. Streets are listed in order from north to south.

The third line contains a string of length m, made of characters '^' and 'v', denoting direction of each vertical street. If the i-th character is equal to '^', the street is directed from south to north, otherwise the street is directed from north to south. Streets are listed in order from west to east.

Output

If the given pattern meets the mayor's criteria, print a single line containing "YES", otherwise print a single line containing "NO".

Sample Input

Input
3 3
><>
v^v
Output
NO
Input
4 6
<><>
v^v^v^
Output
YES


小结:

        果然,一个人没有脑洞是不行的...脑洞大开后很轻易的就可以发现这道题是一道彻彻底底的水题!!

以下是AC代码:

#include<stdio.h>
#include<string.h>
char x[30],y[30];
int main()
{
    int row,col;
    scanf("%d%d",&row,&col);
    scanf("%s",x+1);
    scanf("%s",y+1);
    if((x[1]=='<'&&y[1]=='^')||(x[row]=='<'&&y[1]=='v')||(x[1]=='>'&&y[col]=='^')||(x[row]=='>'&&y[col]=='v'))
    printf("NO\n");
    else
    printf("YES\n");
    return 0;
}

Loading pipeline components...: 100%|██████████████████████████████████████████████████████████████████████████████████| 6/6 [00:09<00:00, 1.56s/it] You have disabled the safety checker for <class 'diffusers.pipelines.stable_diffusion.pipeline_stable_diffusion.StableDiffusionPipeline'> by passing `safety_checker=None`. Ensure that you abide to the conditions of the Stable Diffusion license and do not expose unfiltered results in services or applications open to the public. Both the diffusers team and Hugging Face strongly recommend to keep the safety filter enabled in all public facing circumstances, disabling it only for use-cases that involve analyzing network behavior or auditing its results. For more information, please have a look at https://github.com/huggingface/diffusers/pull/254 . Token indices sequence length is longer than the specified maximum sequence length for this model (1513 > 77). Running this sequence through the model will result in indexing errors The following part of your input was truncated because CLIP can only handle sequences up to 77 tokens: [". a sunlit sky gives a daytime feel but could be bright or maybe at night for a different vibe . adding clouds and birds in flight can enhance the futuristic feel without being too distracting . now , the city itself . neon lights are essential — like the ones on buildings , streets , and vehicles . they create that glowing effect which is common in sci - fi settings . the streetlamps should have a modern twist , maybe with neon colors changing over time to show a dynamic look . flying cars need to stand out . maybe have a variety like convertibles , sports cars , and trucks for realism . the colors could shift based on the type — like metallic blue for a sleek car and neon yellow for something flashy . adding white led lights around the wheels would make them pop . the interiors of these cars should be high - tech . glass windows with holographic digits display info while privacy screens keep passengers safe . seats made from something futuristic , maybe carbon fiber or something that looks high - end . the controls on the dashboard could have touch - sensitive panels for a smooth experience . the city 's architecture is another point . tall skyscrapers with transparent facades letting neon light through gives an otherworldly effect . skyscrapers as flying pads where people can take off into space adds a cool element , and a central hub or floating island with its own skyline would make the city feel interconnected . lighting effects are crucial . neon signs that react to movement using led technology could add some dynamism without being too bright . mirrors on buildings reflecting light like a digital canvas makes them look more alive and interactive . including technology elements , like plasma displays on walls showing info or projections onto flying cars adds depth . the city as a living organism with pulses of neon lights and moving parts gives it a life - like feel despite being man - made . in the evening , the city becomes an illuminated maze where lights dance and flicker , creating an ethereal atmosphere . at night , spaceships take off from docking stations add another dimension to the futuristic vibe . i should also consider how these elements work together . the flying cars moving through neon - lit streets with skyscrapers reflecting light creates a seamless , interconnected cityscape . the high - tech interiors enhance the futuristic theme without overwhelming the viewer . overall , this cityscape is a blend of high technology and vibrant colors that make it look both luxurious and thrilling . it 's designed to evoke an exciting environment where innovation meets entertainment . </ think > the concept of a futuristic cityscape featuring flying cars and neon lights is a classic sci - fi image that has been popularized in movies , video games , and architectural designs . here ’ s how such a cityscape might be imagined : ### 1 . ** sky as the backdrop ** - the sky would be either sunlit or at night , casting a glow on the clouds and reflecting off of birds flying overhead . - a few planes glide past in the distance , adding to the sense of air travel . ### 2 . ** the city itself ** - the city is a seamless , futuristic metropolis where architecture and technology are at their finest . - ** neon lights **: every building has neon signs that pulse and flicker in time with music or ambient sounds . the lights on the buildings could change colors , patterns , and even respond to movement ( e . g ., cars passing by ). - ** falling skies **: a thin , glowing barrier of light orbits the city at night , creating an ethereal effect . - ** sky - light **: a network of small solar - powered lamps suspended in mid - air that provide soft , diffused light to a wider area . ### 3 . ** flying cars ** - flying cars are abundant and serve as transportation throughout the city . - they come in various types : convertibles , sports cars ( with no engines but pure aerodynamics ), and cargo trucks for those who need to carry packages or people . - the exterior of these cars is covered in sleek materials that reflect the neon light . the interiors are high - tech , with glass windows displaying holographic digits while privacy screens cover sensitive information . - the tires have white led lights that glow as you ride , and the wheels spin when you brake or accelerate . ### 4 . ** car interiors ** - the seats are made of a material that seems almost liquid - like , with buttons on the dashboard that respond to touch ( e . g ., pressing them changes the car ’ s interior lights ). - the steering wheel is covered in holographic panels that show real - time data about speed , temperature , or other parameters . - seats are made from high - tech carbon fiber that can be reconfigured . ### 5 . ** the skyscraper metropolis ** - ** tall buildings **: the city ’ s skyscrapers have transparent facades that allow the neon lights to filter through and create a dazzling effect on the streets below . - ** sky - light as flying platforms **: at the top of some skyscrapers , there are platforms or landing pads where people can take off into space via flying cars . - ** central hub **: the city has a central hub or floating island that serves as a convergence point for all traffic and has its own miniature metropolis with neon - lit buildings . ### 6 . ** lighting effects ** - ** neon reactions **: neon signs react to movement , such as people walking through them ( the lights change color based on the surrounding environment ). - ** mirror reflections **: the glass exteriors of the skyscrapers reflect and refract the neon light into a kaleidoscope of patterns . - ** plasma lighting **: walls or ceilings have plasma panels that show changing colors and messages in real - time . ### 7 . ** the night city ** - at night , the city becomes an illuminated maze as lights dance and flicker in rhythm with music played by holographic performers embedded in buildings . - some areas are completely dark except for the neon lights of individual cars or buildings . ### 8 . ** higher - ledgered spaceships ** - the city is connected to outer space via a network of small , floating spaceships that orbit above ground and dock at the skyscrapers . - these spaceships have their own versions of flying cars with high - tech interiors and are constantly being serviced by shuttles from the city . ### 9 . ** interactive features ** - the neon lights on the buildings react to the presence of people , creating an interactive experience as they move through the city . - some buildings have holographic walls that project digital canvases onto them , changing with music or messages . ### 1 0 . ** the sky is the limit ** - the entire city seems to be floating on a layer of neon light , giving the impression of being part of an organism rather than a machine . - at night , the city pulses and breathes , with lights reacting to air traffic as if it were alive . this futuristic cityscape would combine high - tech elements like flying cars , advanced materials , and dynamic lighting to create a place that is both luxurious and thrilling . it would be designed to evoke excitement and wonder while also showcasing cutting - edge technology in architecture and transportation ."]
最新发布
08-26
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符  | 博主筛选后可见
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值