zoukankan      html  css  js  c++  java
  • Codeforces Round #438 by Sberbank and Barcelona Bootcamp (Div. 1 + Div. 2 combine

    最近只想喊666,因为我是真得菜,大晚上到网吧打代码还是很不错的嘛

    A. Bark to Unlock
    time limit per test
    2 seconds
    memory limit per test
    256 megabytes
    input
    standard input
    output
    standard output

    As technologies develop, manufacturers are making the process of unlocking a phone as user-friendly as possible. To unlock its new phone, Arkady's pet dog Mu-mu has to bark the password once. The phone represents a password as a string of two lowercase English letters.

    Mu-mu's enemy Kashtanka wants to unlock Mu-mu's phone to steal some sensible information, but it can only bark n distinct words, each of which can be represented as a string of two lowercase English letters. Kashtanka wants to bark several words (not necessarily distinct) one after another to pronounce a string containing the password as a substring. Tell if it's possible to unlock the phone in this way, or not.

    Input

    The first line contains two lowercase English letters — the password on the phone.

    The second line contains single integer n (1 ≤ n ≤ 100) — the number of words Kashtanka knows.

    The next n lines contain two lowercase English letters each, representing the words Kashtanka knows. The words are guaranteed to be distinct.

    Output

    Print "YES" if Kashtanka can bark several words in a line forming a string containing the password, and "NO" otherwise.

    You can print each letter in arbitrary case (upper or lower).

    Examples
    input
    ya
    4
    ah
    oy
    to
    ha
    output
    YES
    input
    hp
    2
    ht
    tp
    output
    NO
    input
    ah
    1
    ha
    output
    YES
    Note

    In the first example the password is "ya", and Kashtanka can bark "oy" and then "ah", and then "ha" to form the string "oyahha" which contains the password. So, the answer is "YES".

    In the second example Kashtanka can't produce a string containing password as a substring. Note that it can bark "ht" and then "tp" producing "http", but it doesn't contain the password "hp" as a substring.

    In the third example the string "hahahaha" contains "ah" as a substring.

    这个题就是暴力,要不s是p的子串,要不存在两个字符串可以拼成s,因为长度都是2,直接暴力枚举啊

    #include <bits/stdc++.h>
    using namespace std;
    int main()
    {
        string s;
        cin>>s;
        int n;
        scanf("%d",&n);
        string q[110];
        for (int i=0; i<n; i++)
            cin>>q[i];
        for (int i=0; i<n; i++)
        {
            if(q[i]==s)return 0*puts("YES");
            for (int j=0; j<n; j++)
                if (q[i][0]==s[1]&&q[j][1]==s[0])return 0*puts("YES");
        }
        puts("NO");
        return 0;
    }
    B. Race Against Time
    time limit per test
    2 seconds
    memory limit per test
    256 megabytes
    input
    standard input
    output
    standard output

    Have you ever tried to explain to the coordinator, why it is eight hours to the contest and not a single problem has been prepared yet? Misha had. And this time he has a really strong excuse: he faced a space-time paradox! Space and time replaced each other.

    The entire universe turned into an enormous clock face with three hands — hour, minute, and second. Time froze, and clocks now show the time h hours, m minutes, s seconds.

    Last time Misha talked with the coordinator at t1 o'clock, so now he stands on the number t1 on the clock face. The contest should be ready by t2 o'clock. In the terms of paradox it means that Misha has to go to number t2 somehow. Note that he doesn't have to move forward only: in these circumstances time has no direction.

    Clock hands are very long, and Misha cannot get round them. He also cannot step over as it leads to the collapse of space-time. That is, if hour clock points 12 and Misha stands at 11 then he cannot move to 1 along the top arc. He has to follow all the way round the clock center (of course, if there are no other hands on his way).

    Given the hands' positions, t1, and t2, find if Misha can prepare the contest on time (or should we say on space?). That is, find if he can move from t1 to t2 by the clock face.

    Input

    Five integers hmst1, t2 (1 ≤ h ≤ 12, 0 ≤ m, s ≤ 59, 1 ≤ t1, t2 ≤ 12, t1 ≠ t2).

    Misha's position and the target time do not coincide with the position of any hand.

    Output

    Print "YES" (quotes for clarity), if Misha can prepare the contest on time, and "NO" otherwise.

    You can print each character either upper- or lowercase ("YeS" and "yes" are valid when the answer is "YES").

    Examples
    input
    12 30 45 3 11
    output
    NO
    input
    12 0 1 12 1
    output
    YES
    input
    3 47 0 4 9
    output
    YES
    Note

    The three examples are shown on the pictures below from left to right. The starting position of Misha is shown with green, the ending position is shown with pink. Note that the positions of the hands on the pictures are not exact, but are close to the exact and the answer is the same.


  • 相关阅读:
    xhtml中隐藏滚动条
    一个题目包括70种网页制作常用技巧 (转)
    Oracle 数据类型映射 (ADO.NET)
    oracle数据库 数据类型
    VisualSVN Server的配置和使用方法
    oracle 权限管理
    项目管理实践【三】每日构建【Daily Build Using CruiseControl.NET and MSBuild】
    showModalDialog和showModelessDialog使用心得
    Bug跟踪管理【Bug Trace and Management】
    开发WAP站点之使用PC电脑浏览器访问WAP手机站点 (转)
  • 原文地址:https://www.cnblogs.com/BobHuang/p/7634037.html
Copyright © 2011-2022 走看看