Codeforces Round #300

Source: Internet
Author: User
Tags join split
Http://codeforces.com/contest/538A. Cutting Banner
S=raw_input ()
flag = 0 for
i in range (len (s)):
    for J in range (I, Len (s)):
        if (s[:i]+s[j+1:] = = ' Codeforces '):
            flag = 1
if (flag==1):
    print ' YES '
else:
    print ' NO '
B. Quasi Binary
n = input ()
ans = [] while
n > 0:
    tmp = n
    i = 0
    y = 1
    res = 0 while
    tmp > 0:x = tmp%10
        tmp/=
        if x > 0:
            res + = y
        y *=
    N-= res
    ans.append (res)
print len ( ANS)
print ". Join (Map (str, ans))
C. Tourist ' s Notes
N, m = map (int, raw_input (). Split ())
PD, ph = map (int, raw_input (). Split ())
ans = ph+pd-1 for
i in range (m-1):
    d, h = map (int, raw_input (). Split ())
    xd = d-pd
    XH = ABS (H-PH)
    if XH > xd:
        print ' Impossible '
        E XIT ()
    tmp = (d-pd+h+ph)/2
    ans = max (ans, tmp)
    PD = d
    ph = h
ans = max (ans, ph+n-pd)
print ans
D. Weird chess Below is a python timeout code, changed to C + + can be ... No problem. Enumerate each position, determine whether to put ' x ', if relative to each o, there is no ' x ', then do not need, if one is ' x ', then need to turn him into ' X ', and finally judge whether it is legal ...
n = input()
mp = []
a = []
b = []
for i in range(n):
    s = raw_input()
    for j, ch in enumerate(s):
        if ch == 'o':
            a.append((i,j))
    mp.append(s)
ans = [['.' for i in range(2*n-1)] for i in range(2*n-1)]
ans2 = [['.' for i in range(n)] for i in range(n)]
tmp = 0
l = len(a)
for i in range(2*n-1):
    for j in range(2*n-1):
        sum1 = 0
        for oo in a:
            tx = oo[0]+(i+1-n)
            ty = oo[1]+(j+1-n)
            if tx<0 or tx>=n or ty<0 or ty>=n :
                sum1 += 1
                continue
            elif mp[tx][ty] == 'o' or mp[tx][ty] == 'x':
                sum1 = sum1+1
            else:
                break
        if sum1 == l:
            b.append((i,j))
            ans[i][j] = 'x'
for pp in b:
    for oo in a:
        tx = oo[0]+(pp[0]+1-n)
        ty = oo[1]+(pp[1]+1-n)
        if tx<0 or tx>=n or ty<0 or ty>=n :
            continue
        ans2[tx][ty] = 'x';
for i in range(n):
    for j in range(n):
        if mp[i][j] == 'o' or ans2[i][j] == 'o':
            continue
        if mp[i][j] != ans2[i][j]:
            tmp = 1
            break
if tmp:
    print 'NO'
else:
    ans[n-1][n-1] = 'o'
    print 'YES'
    for i in range(2*n-1):
        print ''.join(ans[i])
E. demiurges Play again tree DPF. A Heap of heaps matrix fast power

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.