Problem:


Score: 200 points

Problem Statement

Takahashi will do a tap dance. The dance is described by a string S where each character is L, R, U, or D. These characters indicate the positions on which Takahashi should step. He will follow these instructions one by one in order, starting with the first character.

S is said to be easily playable if and only if it satisfies both of the following conditions:

Every character in an odd position (1-st, 3-rd, 5-th, \ldots) is R, U, or D.

Every character in an even position (2-nd, 4-th, 6-th, \ldots) is L, U, or D.

Your task is to print Yes if S is easily playable, and No otherwise.

Constraints

S is a string of length between 1 and 100 (inclusive).

Each character of S is L, R, U, or D.

Input

Input is given from Standard Input in the following format:

S

Output

Print Yes if S is easily playable, and No otherwise.

Sample Input 1

RUDLUDR

Sample Output 1

Yes

Every character in an odd position (1-st, 3-rd, 5-th, 7-th) is R, U, or D.

Every character in an even position (2-nd, 4-th, 6-th) is L, U, or D.

Thus, S is easily playable.

Sample Input 2

DULL

Sample Output 2

No

The 3-rd character is not R, U, nor D, so S is not easily playable.

Sample Input 3

UUUUUUUUUUUUUUU

Sample Output 3

Yes

Sample Input 4

ULURU

Sample Output 4

No

Sample Input 5

RDULULDURURLRDULRLR

Sample Output 5

Yes



Sample input:
RUDLUDR


Sample output:
Yes

Submission status: Runtime Error

Solution code:
#include <stdio.h>

int main()
{
    char s[110];
    scanf("%s",s);

    bool ans=true;
    int len;
    for(int i=0;;i++)
    {
        if(s[i]=='\0')
        {
            len=i;
            break;
        }
    }
    for(int i=0;i<len;i+=2)
    {
        if(s[i]!='R'&&s[i]!='U'&&s[i]!='D')
        {
            ans=false;
            break;
        }
    }
    for(int i=1;i<len;i+=2)
    {
        if(ans&&s[i]!='L'&&s[i]!='U'&&s[i]!='D')
        {
            ans=false;
            break;
        }
    }
    if(ans) printf("Yes\n");
    else printf("No\n");
}

Submission status: Runtime Error

Solution code:
S = input()

for s in S[0::2]:
    if s != 'R' and s != 'U' and s != 'D':
        print('No')
        quit()

for i in S[1::2]:
    if S[i] != 'L' and S[i] != 'U' and S[i] != 'D':
        print('No')
        quit()

print('Yes')

Submission status: Runtime Error

Solution code:
s = input()
count = 1
for i in s:
    if (count % 2 == 1) and ( i == 'L'):
        flag = False
        count += 1
    elif (count % 2 == 0) and (i == 'R'):
        flag = False
        count += 1
    else:
        count += 1
if flag:
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

Solution code:
S = input()

even = set({})
odd = set({})
for i in range(len(S)):
    if i % 2 == 0:
        even.add(S[i])
    else:
        odd.add(S[i])
print(even, odd)

if (not "R" in odd) and (not "L" in even):
    print("Yes")
else:
    print("No"

Submission status: Runtime Error

Solution code:
def main():
    result = 'Yes'
    S = str(input())
    for i in range(len(S)):
        if(i%2==0):#index=0は1文字目なので奇数ルール
            if(S[i]=='L'):
                result = 'No'
                break
        else:#偶数ルール
            if(S[i]=='R'):
                result = 'No'
                breakpoint
    print(result)

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
s = input()

import sys

for i in range(len(s)):
    if (i + 1) % 2 == 1 and s[i] not in 'RUD':
        print('No')
        sys.exit(1)
    if (i + 1) % 2 == 0 and s[i] not in 'LUD':
        print('No')
        sys.exit(1)
print('Yes')

Submission status: Runtime Error

Solution code:
S = input()
S_odd = [s for i, s in enumerate(S) if i % 2 == 0]
S_even = [s for i, s in enumerate(S) if i % 2 != 0]

for i in S_odd:
    if i in ['R', 'U', 'D']:
        f = 1
    else:
        f = 0
        break
for j in S_even:
    if j in ['L', 'U', 'D']:
        g = 1
    else:
        g = 0
        break
if f*g:
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

Solution code:
S=input()
s=0
for i in range(len(S)):
  if i%2==0:
    if S[i]=="R" or "U" or "D":
      s+=1
  else:
    if S[i]="L" or "U" or "D":
      s+=1
if s==len(S):
  print("Yes")
else:
  print("No")

Submission status: Runtime Error

Solution code:
#include<bits/stdc++.h>
using namespace std;
char ch[500000];
int main(){
	scanf("%s",ch);
	int len=strlen(ch);
	for(int i=0;i<len;i++){
		if((i%2==1&&ch[i]=='R') || (!(i%2)&&ch[i]=='L')){
			printf("No");
			return 0;
		}
	}
	printf("Yes");
	return 0;
}

Submission status: Runtime Error

Solution code:
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
	"strings"

)


func main() {
	solve(os.Stdin, os.Stdout)
}

type ReaderEx struct {
	baseScanner *bufio.Scanner
	words       []string
	nextWordIdx func() int
	initWordIdx func(int)
}

func NewScannerEx(stdin io.Reader) *ReaderEx {
	var this ReaderEx
	var idx int
	var wordsCnt int
	this.baseScanner = bufio.NewScanner(stdin)
	this.baseScanner.Buffer(make([]byte, 0), 1E+11)
	this.nextWordIdx = func() int {
		cur := idx
		idx = (idx + 1) % wordsCnt
		return cur
	}
	this.initWordIdx = func(wc int) {
		idx = 0
		wordsCnt = wc
	}
	return &this
}

func (me *ReaderEx) Scan(doSplit bool) (isScanned bool) {
	isScanned = me.baseScanner.Scan()
	if doSplit {
		me.words = strings.Fields(me.baseScanner.Text())
	} else {
		me.words = []string{me.baseScanner.Text()}
	}
	me.initWordIdx(len(me.words))
	return
}

func (me *ReaderEx) nextBytes() []byte {
	return []byte(me.words[me.nextWordIdx()])
}
func (me *ReaderEx) nextString() string {
	return me.words[me.nextWordIdx()]
}

type StringArray []string

func (me *ReaderEx) nextStringArray() StringArray {
	return me.words[me.nextWordIdx():]
}

func (me StringArray) toStrings() []string {
	return me
}

func (me StringArray) toInts() []int {
	strValues := me.toStrings()
	values := make([]int, len(strValues))
	for i, v := range strValues {
		n, err := strconv.Atoi(v)
		if err != nil {
			panic(err)
		}
		values[i] = n
	}
	return values
}
func (me *ReaderEx) nextInt() int {
	n, err := strconv.Atoi(me.words[me.nextWordIdx()])

	defer func() {
		if err != nil {
			panic(fmt.Sprintf("getInt(%d)", n))
		}
	}()
	return n
}

func pow(x, y, mod int) (ans int) {

	ans = 1
	for bit := 1 << uint(math.Floor(math.Log2(float64(y)))); ; bit >>= 1 {
		if y&bit != 0 {
			ans *= x
			if mod > 0 {
				ans %= mod
			}
		}
		if bit <= 1 {
			return
		}
		ans *= ans
		if mod > 0 {
			ans %= mod
		}
	}
}

type factType struct {
	prime int
	count int
}

func fact(n int) (facts []*factType) {

	for i := 2; i*i <= n; i++ {
		if n%i == 0 {
			fa := factType{prime: i}
			for n%fa.prime == 0 {
				n /= fa.prime
				fa.count++
			}
			facts = append(facts, &fa)
		}
	}
	if n > 1 {
		facts = append(facts, &factType{prime: n, count: 1})
	}
	return facts
}
func dec2bin(n int) (ret []bool) {
	for bit := 1 << uint(math.Floor(math.Log2(float64(n)))); ; bit >>= 1 {
		ret = append(ret, n&bit != 0)

		if bit <= 1 {
			return
		}
	}

}

func abs(v int) int {
	if v < 0 {
		v = -v
	}
	return v
}

func b2i(b bool) (i int) {
	if b {
		i = 1
	} else {
		i = 0
	}
	return
}

func solve(stdin io.Reader, stdout io.Writer) {

	r := NewScannerEx(stdin)
	r.Scan(true)
	s := r.nextString()

	ans := true
	for i := range s {
		if (i+1)%2 == 0 {
			if s[i] == 'R' {
				ans = false
				break
			}
		} else {
			if s[i] == 'L' {
				ans = false
				break
			}
		}
	}
	fmt.Fprintln(stdout, []string{"No", "Yes"}[b2i(ans)])
}

Submission status: Runtime Error

Solution code:
s=input()

n=len(s)
for i in range(0,n,2):

  if s[i] == "R" or s[i] =="U" or s[i] =="D":
    flag1=True
  else:
    flag1=False
for i in range(1,n,2):
  if s[i] == "L" or s[i] =="U" or s[i] =="D":
    flag2=True
  else:
    flag2=False

if flag1 == True and flag2 == True:
  print("Yes")
else:
  print("No")

Submission status: Runtime Error

Solution code:
a = "Yes"
for i,s in enumerate(S):
    if i % 2 == 0:
        if s in ["R", "U", "D"]:
            pass
        else:
            a = "No"
            break
    else:
        if s in ["L", "U", "D"]:
            pass
        else:
            a = "No"
            break
            
print(a)

Submission status: Runtime Error

Solution code:
s = list(input())
a = s[::2]
b = s[1::2]
if a.count(L) == 0 and b.count(R) == 0:
  print('Yes')
else:
  print("No")

Submission status: Runtime Error

Solution code:
s=input()
flag = True
for i in range(len(s)):
  if (i % 2 == 0 and s[i] == 'L') or (i % 2 == 1 and s[i] == 'R')
    flag = False
if flag:
  print("Yes")
else:
  print("No")

Submission status: Runtime Error

Solution code:
s=input()
flag = True
for i in range(n):
  if (i % 2 == 0 and s[i] == 'L') or (i % 2 == 1 and s[i] == 'R')
    flag = False
if flag:
  print("Yes")
else:
  print("No")

Submission status: Runtime Error

Solution code:
s = input()
for i, j in enumerate(s):
	if i % 2 == 0 and j == 'L':
		print('No')
        return
    elif i % 2 == 1 and j == 'R':
		print('No')
        return
print('Yes')

Submission status: Runtime Error

Solution code:
s = input()
nocounter = 0
n = len(s)

for i in range(n):
  if (i % 2 == 0):
    if s[i] == "L":
      print("No")
      nocounter = 1
      break
  if (i % 2 == 1):
    if s[i] == "R":
      print("No"):
      nocounter = 1
      break
      
if (nocounter = 0):
  print("Yes")

Submission status: Runtime Error

Solution code:
import algorithm, future, hashes, macros, math, sequtils, sets, strutils, tables, times, unicode, queues
 
macro unpack(rhs: seq, cnt: static[int]): auto =
  let t = genSym(); result = quote do:(let `t` = `rhs`;())
  if NimMinor <= 17:
    for i in 0..<cnt: result[0][1].add(quote do:`t`[`i`])
  else:
    for i in 0..<cnt: result[1].add(quote do:`t`[`i`])
 
template input(T: typedesc, cnt: Natural = 1): untyped =
  let line = stdin.readLine.split(" ")
  when T is int:         line.map(parseInt).unpack(cnt)
  elif T is float:       line.map(parseFloat).unpack(cnt)
  elif T is string:      line.unpack(cnt)
  elif T is char:        line.mapIt(it[0]).unpack(cnt)
  elif T is seq[int]:    line.map(parseInt)
  elif T is seq[float]:  line.map(parseFloat)
  elif T is seq[string]: line
  elif T is seq[char]:   line.mapIt(it[0])

proc floorMod*[T: SomeNumber](x, y: T): T =
  result = x mod y
  if (result > 0 and y < 0) or (result < 0 and y > 0): result += y

proc `%`(n,m:int):int = floorMod(n,m)
proc `%=`(n: var int, m: int)  = n = floorMod(n,m)
proc `//=`(n: var int, m: int) = n = n div m
proc `<<=`(n: var int, m: int) = n = n shl m
proc `>>=`(n: var int, m: int) = n = n shr m
proc `<?=`(n: var int, m: int) = n = min(n, m)
proc `>?=`(n: var int, m: int) = n = max(n, m)
proc newSeq2[T](n1, n2: Natural): seq[seq[T]] = newSeqWith(n1, newSeq[T](n2))
proc newSeq3[T](n1, n2, n3: Natural): seq[seq[seq[T]]] = newSeqWith(n1, newSeqWith(n2, newSeq[T](n3)))

proc spacingStr(things: varargs[string,`$`]):string =
  for thing in things:
    result &= thing
    result &= " "
  result &= "\n"
proc spacingStr[T](things: seq[T]):string =
  for thing in things:
    result &= $thing
    result &= " "
  result &= "\n"
proc spacingStr[T](things: seq[seq[T]]):string =
  for thing in things:
    result &= spacingStr(thing)
proc spacingStrPlusOne(things: varargs[int]):string =
  for thing in things:
    result &= $(thing+1)
    result &= " "
  result &= "\n"
proc spacingStrPlusOne[T](things: seq[T]):string =
  for thing in things:
    result &= $(thing+1)
    result &= " "
  result &= "\n"
proc spacingStrPlusOne[T](things: seq[seq[T]]):string =
  for thing in things:
    result &= spacingStrPlusOne(thing)
proc spacingEcho(things: varargs[string,`$`]) = stdout.write(spacingStr(things))
proc spacingEcho[T](things: seq[T]) = stdout.write(spacingStr(things))
proc spacingEcho[T](things: seq[seq[T]]) = stdout.write(spacingStr(things))
proc spacingEchoPlusOne(things: varargs[int]) = stdout.write(spacingStrPlusOne(things))
proc spacingEchoPlusOne(things: seq[int]) = stdout.write(spacingStrPlusOne(things))
proc spacingEchoPlusOne(things: seq[seq[int]]) = stdout.write(spacingStrPlusOne(things))
template myDump*(things: varargs[string,`$`]) =
  when NimMinor >= 17:
    let sr = spacingStr(things)
    let line = instantiationInfo().line
    let lineName = "LINE" & '0'.repeat(4-($line).len) & ($line) & "...>  "
    stdout.write(lineName & sr)
template myDump*[T](things: seq[T]) =
  when NimMinor >= 17:
    let sr = spacingStr(things)
    let line = instantiationInfo().line
    let lineName = "LINE" & '0'.repeat(4-($line).len) & ($line) & "...>  "
    stdout.write(lineName & sr)
template myDump*[T](things: seq[seq[T]]) =
  when NimMinor >= 17:
    let sr = spacingStr(things)
    let line = instantiationInfo().line
    let lineName = "LINE" & '0'.repeat(4-($line).len) & ($line) & "...v\n"
    stdout.write(lineName & sr)
iterator items(n:int):int = 
  for i in 0..<n:
    yield i

let S = input(string)
for i,c in S:
  if i%2==0:
    if c=='L':
      echo "No"
      quit()
  else:
    if c=='R':
      echo "No"
      quit()

echo "Yes"
quit()

Submission status: Runtime Error

Solution code:
s=input()
a=s[1::2]
b=[::2]
if "L" not in b and "R" not in a:print("Yes")
else:print("No")