prompt string | response string |
|---|---|
Problem: Mikhail walks on a 2D plane. He can go either up or right. You are given a sequence of Mikhail's moves. He thinks that this sequence is too long and he wants to make it as short as possible.
In the given sequence moving up is described by character U and moving right is described by character R. Mikhail can r... | #include <bits/stdc++.h>
using namespace std;
const long long int N = 1e9 + 7;
vector<long long> v1;
int main() {
int n, i, r = 0;
scanf("%d", &(n));
string s;
cin >> s;
if (n == 1) return cout << 1 << endl, 0;
std::vector<char> v;
v.push_back(s[0]);
for (int i = (1); i < n; i++) {
if (v.size() > 0 ... |
Problem: Mikhail walks on a 2D plane. He can go either up or right. You are given a sequence of Mikhail's moves. He thinks that this sequence is too long and he wants to make it as short as possible.
In the given sequence moving up is described by character U and moving right is described by character R. Mikhail can r... | import java.util.Scanner;
public class P954A
{
public static void main(String[] args)
{
Scanner scan = new Scanner(System.in);
int n = scan.nextInt();
char[] in = scan.next().toCharArray();
int len = 0;
for (int i = 0; i < in.length; i++)
{
if (i == in.length-1)
len++;
else if (in[i] == 'R' && ... |
Problem: Mikhail walks on a 2D plane. He can go either up or right. You are given a sequence of Mikhail's moves. He thinks that this sequence is too long and he wants to make it as short as possible.
In the given sequence moving up is described by character U and moving right is described by character R. Mikhail can r... | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual soluti... |
Problem: Mikhail walks on a 2D plane. He can go either up or right. You are given a sequence of Mikhail's moves. He thinks that this sequence is too long and he wants to make it as short as possible.
In the given sequence moving up is described by character U and moving right is described by character R. Mikhail can r... | tamanho = int(input())
ru = "RU"
ur = "UR"
caminho = input()
menorCaminho = ""
if(len(caminho) == 1):
menorCaminho = caminho
else:
i = 0
while(i <= len(caminho) - 1):
if((len(caminho) // 2) != 0 and i == tamanho - 1):
menorCaminho += caminho[-1]
i += 1
elif(caminho[i] + caminho[i+1] == ur ... |
Problem: Mikhail walks on a 2D plane. He can go either up or right. You are given a sequence of Mikhail's moves. He thinks that this sequence is too long and he wants to make it as short as possible.
In the given sequence moving up is described by character U and moving right is described by character R. Mikhail can r... | n = int(input())
last = None
for mv in input():
if last and mv != last:
last = None
n -= 1
else:
last = mv
print(n)
|
Problem: Mikhail walks on a 2D plane. He can go either up or right. You are given a sequence of Mikhail's moves. He thinks that this sequence is too long and he wants to make it as short as possible.
In the given sequence moving up is described by character U and moving right is described by character R. Mikhail can r... | asd=int(input())
l=input()
count=0
i=0
while i < asd:
if i == asd-1:
count+=1
break
if l[i]!=l[i+1]:
i+=2
else:
i+=1
count+=1
print(count) |
Problem: Mikhail walks on a 2D plane. He can go either up or right. You are given a sequence of Mikhail's moves. He thinks that this sequence is too long and he wants to make it as short as possible.
In the given sequence moving up is described by character U and moving right is described by character R. Mikhail can r... | import java.io.*;
import java.util.*;
public class cf5
{
public static void main(String args[]) throws Exception
{
Scanner s=new Scanner(System.in);
int n=s.nextInt();
String str=s.next();
int count=0;
str=str.replaceAll("RU|UR","D");
System.out.println(str.length());
}
} |
Problem: Mikhail walks on a 2D plane. He can go either up or right. You are given a sequence of Mikhail's moves. He thinks that this sequence is too long and he wants to make it as short as possible.
In the given sequence moving up is described by character U and moving right is described by character R. Mikhail can r... | #include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n;
cin >> n;
string s;
cin >> s;
string ss = s, sss;
for (int i = 0; i < 10000; ++i) {
sss = "";
for (int j = 0; j < n;) {
if (ss[j] == 'R' && ss[j + 1] == 'U') {
... |
Problem: Mikhail walks on a 2D plane. He can go either up or right. You are given a sequence of Mikhail's moves. He thinks that this sequence is too long and he wants to make it as short as possible.
In the given sequence moving up is described by character U and moving right is described by character R. Mikhail can r... | /*
####### ###### ##### ###### ###### #####
# # # # # # # # # #
# # # # # # # ## # # ## # #
# # # # # # # # # # #
####### # # # # # # # # # #
*/
import java.io.BufferedReader;
import java.io.IOException;
import j... |
Problem: Mikhail walks on a 2D plane. He can go either up or right. You are given a sequence of Mikhail's moves. He thinks that this sequence is too long and he wants to make it as short as possible.
In the given sequence moving up is described by character U and moving right is described by character R. Mikhail can r... | n=int(input())
S=input()
index = 0
summ=0
while index+1 < n:
if S[index]!=S[index+1]:
summ+=1
index+=1
index +=1
print(n-summ)
|
Problem: Mikhail walks on a 2D plane. He can go either up or right. You are given a sequence of Mikhail's moves. He thinks that this sequence is too long and he wants to make it as short as possible.
In the given sequence moving up is described by character U and moving right is described by character R. Mikhail can r... | n = int(input())
b = []; i = 0
a = list(input()); k = 0
while i < len(a)-1:
if a[i] + a[i+1] == "RU" or a[i] + a[i+1] == "UR": k += 1;i += 1
i += 1
print(len(a)-k) |
Problem: Mikhail walks on a 2D plane. He can go either up or right. You are given a sequence of Mikhail's moves. He thinks that this sequence is too long and he wants to make it as short as possible.
In the given sequence moving up is described by character U and moving right is described by character R. Mikhail can r... | n = int(input())
s = input()
ans = 0
i = 0
while i < n:
if i != n - 1 and s[i] != s[i + 1]:
i += 1
ans += 1
i += 1
print(ans)
|
Problem: Mikhail walks on a 2D plane. He can go either up or right. You are given a sequence of Mikhail's moves. He thinks that this sequence is too long and he wants to make it as short as possible.
In the given sequence moving up is described by character U and moving right is described by character R. Mikhail can r... | #include <bits/stdc++.h>
int main() {
int len;
char str[105];
scanf("%d%s", &len, str);
int cnt = 0;
for (int i = 0; i < len; ++i) {
++cnt;
if (i > 0) {
if ((str[i] == 'R' && str[i - 1] == 'U') ||
(str[i] == 'U' && str[i - 1] == 'R')) {
--cnt;
str[i] = 'D';
}
... |
Problem: Mikhail walks on a 2D plane. He can go either up or right. You are given a sequence of Mikhail's moves. He thinks that this sequence is too long and he wants to make it as short as possible.
In the given sequence moving up is described by character U and moving right is described by character R. Mikhail can r... | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.FilterInputStream;
import java.io.BufferedInputStream;
import java.io.InputStream;
/**
* @author Jenish
*/
public class Main {
public static void main(String[] ARGS) {
new Threa... |
Problem: Mikhail walks on a 2D plane. He can go either up or right. You are given a sequence of Mikhail's moves. He thinks that this sequence is too long and he wants to make it as short as possible.
In the given sequence moving up is described by character U and moving right is described by character R. Mikhail can r... | #include <bits/stdc++.h>
using namespace std;
int main() {
int p = 0, n = 0, i = 0;
string s;
cin >> n >> s;
for (i = 1; i < n; i++) {
if (s[i] != s[i - 1]) {
i++;
p++;
}
}
cout << n - p;
}
|
Problem: Mikhail walks on a 2D plane. He can go either up or right. You are given a sequence of Mikhail's moves. He thinks that this sequence is too long and he wants to make it as short as possible.
In the given sequence moving up is described by character U and moving right is described by character R. Mikhail can r... | n=int(input())
s=input()
k=''
i=0
while(i<n):
if (i!=n-1 and s[i]!=s[i+1]):
k+='D'
i+=2
else:
k+=s[i]
i+=1
print(len(k)) |
Problem: Mikhail walks on a 2D plane. He can go either up or right. You are given a sequence of Mikhail's moves. He thinks that this sequence is too long and he wants to make it as short as possible.
In the given sequence moving up is described by character U and moving right is described by character R. Mikhail can r... | /**
*
*/
//package codeforces;
import java.util.*;
/**
* @author Shivansh Singh
*
*/
public class Cf954A {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc=new Scanner(System.in);
int n,i,c=0;
n=sc.nextInt();
String str=sc.next();
char ... |
Problem: Mikhail walks on a 2D plane. He can go either up or right. You are given a sequence of Mikhail's moves. He thinks that this sequence is too long and he wants to make it as short as possible.
In the given sequence moving up is described by character U and moving right is described by character R. Mikhail can r... | #include <bits/stdc++.h>
using namespace std;
void solve() {
int n;
cin >> n;
string s;
cin >> s;
int ans = n;
for (int i = 0; i < n - 1; i++) {
string check = s.substr(i, 2);
if (check == "RU" || check == "UR") {
ans -= 1;
i++;
}
}
cout << ans << "\n";
}
int main() {
ios_base:... |
Problem: Mikhail walks on a 2D plane. He can go either up or right. You are given a sequence of Mikhail's moves. He thinks that this sequence is too long and he wants to make it as short as possible.
In the given sequence moving up is described by character U and moving right is described by character R. Mikhail can r... | #include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
int n, m, k;
cin >> n;
string s;
cin >> s;
long long int ans = n;
for (int i = 1; i < n; i++) {
if (s.at(i) != s.at(i - 1)) {
ans--;
i++;
}
}
cout << ans;
return 0;
}
|
Problem: Mikhail walks on a 2D plane. He can go either up or right. You are given a sequence of Mikhail's moves. He thinks that this sequence is too long and he wants to make it as short as possible.
In the given sequence moving up is described by character U and moving right is described by character R. Mikhail can r... | import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import java.util.StringTokenizer;
public class Main {
... |
Problem: Mikhail walks on a 2D plane. He can go either up or right. You are given a sequence of Mikhail's moves. He thinks that this sequence is too long and he wants to make it as short as possible.
In the given sequence moving up is described by character U and moving right is described by character R. Mikhail can r... | import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n =in.nextInt();
String str = in.next();
int res = str.length();
for (int i = 0; i < n-1 ; i++) {
if(str.charAt(i)!=str.charAt(i+1))
... |
Problem: Mikhail walks on a 2D plane. He can go either up or right. You are given a sequence of Mikhail's moves. He thinks that this sequence is too long and he wants to make it as short as possible.
In the given sequence moving up is described by character U and moving right is described by character R. Mikhail can r... |
import java.lang.Math;
import java.util.*;
import java.io.*;
public class Solution {
public static void main(String[] args) {
InputStream inputStream = System.in;
OutputStream outputStream = System.out;
InputReader in = new InputReader(inputStream);
PrintWriter out = new PrintWriter(outputStream);
Problem ... |
Problem: Mikhail walks on a 2D plane. He can go either up or right. You are given a sequence of Mikhail's moves. He thinks that this sequence is too long and he wants to make it as short as possible.
In the given sequence moving up is described by character U and moving right is described by character R. Mikhail can r... | x = int(input())
s = str(input())
c = 0
for i in range(len(s)-1):
if (s[i]=='U' and s[i+1]=='R') or (s[i]=='R' and s[i+1]=='U'):
s = s[:i] + "$$" + s[i+2:]
c = c + 1
print (len(s) - c) |
Problem: Mikhail walks on a 2D plane. He can go either up or right. You are given a sequence of Mikhail's moves. He thinks that this sequence is too long and he wants to make it as short as possible.
In the given sequence moving up is described by character U and moving right is described by character R. Mikhail can r... | #include <bits/stdc++.h>
using namespace std;
long long int n, m, t, i, j, c = 0;
string x, y, z;
int main() {
cin >> n >> x;
for (i = 0; i < n - 1;) {
if (x[i] != x[i + 1]) {
c++;
i = i + 2;
} else
i++;
}
cout << (n - c);
}
|
Problem: Mikhail walks on a 2D plane. He can go either up or right. You are given a sequence of Mikhail's moves. He thinks that this sequence is too long and he wants to make it as short as possible.
In the given sequence moving up is described by character U and moving right is described by character R. Mikhail can r... | n = int(input())
s = input()
cnt = 0
while True:
ru = s.find("RU")
ur = s.find("UR")
if ru == ur == -1:
break
if ru == -1:
cnt += 1
s = s.replace("UR", "D", 1)
elif ur == -1:
cnt += 1
s = s.replace("RU", "D", 1)
else:
if ru < ur:
s = s... |
Problem: Mikhail walks on a 2D plane. He can go either up or right. You are given a sequence of Mikhail's moves. He thinks that this sequence is too long and he wants to make it as short as possible.
In the given sequence moving up is described by character U and moving right is described by character R. Mikhail can r... | import java.util.Scanner;
public class A954 {
public static void main(String[] args){
int n,count=0;
Scanner in= new Scanner(System.in);
n= in.nextInt();
String way= in.next();
//CharSequence way1= "RU";
//CharSequence way2= "UR";
CharSequence way3= "D1";
... |
Problem: Mikhail walks on a 2D plane. He can go either up or right. You are given a sequence of Mikhail's moves. He thinks that this sequence is too long and he wants to make it as short as possible.
In the given sequence moving up is described by character U and moving right is described by character R. Mikhail can r... | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
string s;
cin >> s;
int c = 0;
while (1) {
bool ok = false;
for (int i = 0; i < s.size(); i++) {
if ((s[i] == 'R' && s[i + 1] == 'U') || s[i] == 'U' && s[i + 1] == 'R') {
ok = true;
s[i] = 'D';
... |
Problem: Mikhail walks on a 2D plane. He can go either up or right. You are given a sequence of Mikhail's moves. He thinks that this sequence is too long and he wants to make it as short as possible.
In the given sequence moving up is described by character U and moving right is described by character R. Mikhail can r... | /*
* Author: Minho Kim (ISKU)
* Date: March 22, 2018
* E-mail: minho.kim093@gmail.com
*
* https://github.com/ISKU/Algorithm
* http://codeforces.com/problemset/problem/954/A
*/
import java.util.*;
public class A {
public static void main(String... args) {
Scanner sc = new Scanner(System.in);
int N = sc.nex... |
Problem: Mikhail walks on a 2D plane. He can go either up or right. You are given a sequence of Mikhail's moves. He thinks that this sequence is too long and he wants to make it as short as possible.
In the given sequence moving up is described by character U and moving right is described by character R. Mikhail can r... | input()
s = input()
i = 0
nd = 0
while i < len(s) - 1:
if s[i] != s[i + 1]:
nd += 1
i += 1
i += 1
print(len(s) - nd)
|
Problem: Mikhail walks on a 2D plane. He can go either up or right. You are given a sequence of Mikhail's moves. He thinks that this sequence is too long and he wants to make it as short as possible.
In the given sequence moving up is described by character U and moving right is described by character R. Mikhail can r... | n=int(input())
s=input()
t,c=0,0
while t<=len(s):
if s[t:t+2]=='UR' or s[t:t+2]=='RU':
c+=1
t+=2
else:
c+=1
t+=1
print(c-1) |
Problem: Mikhail walks on a 2D plane. He can go either up or right. You are given a sequence of Mikhail's moves. He thinks that this sequence is too long and he wants to make it as short as possible.
In the given sequence moving up is described by character U and moving right is described by character R. Mikhail can r... | n = int(input())
s = input()
j = 0
num = 0
while j < n:
if j < n - 1 and s[j: j + 2] == "RU" or s[j: j + 2] == "UR":
j += 2
num += 1
else:
j += 1
num += 1
print(num)
|
Problem: Mikhail walks on a 2D plane. He can go either up or right. You are given a sequence of Mikhail's moves. He thinks that this sequence is too long and he wants to make it as short as possible.
In the given sequence moving up is described by character U and moving right is described by character R. Mikhail can r... | //package competitive.coding;
import java.io.*;
import java.util.*;
/******************************************
* AUTHOR: AMAN KUMAR SINGH *
* INSTITUITION: KALYANI GOVERNMENT ENGINEERING COLLEGE *
******************************************/
public class CompetitiveCoding{
public static vo... |
Problem: Mikhail walks on a 2D plane. He can go either up or right. You are given a sequence of Mikhail's moves. He thinks that this sequence is too long and he wants to make it as short as possible.
In the given sequence moving up is described by character U and moving right is described by character R. Mikhail can r... | import re
i=input
i()
print(len(re.sub('UR|RU','D',i()))) |
Problem: Mikhail walks on a 2D plane. He can go either up or right. You are given a sequence of Mikhail's moves. He thinks that this sequence is too long and he wants to make it as short as possible.
In the given sequence moving up is described by character U and moving right is described by character R. Mikhail can r... | import java.util.Scanner;
public class Main {
static Scanner read=new Scanner(System.in);
public static void main(String[] args) {
// TODO ApΓ©ndice de mΓ©todo generado automΓ‘ticamente
int lim=read.nextInt();
String cad=read.next();
String aux="";
boolean p=true;
for (int i = 0; i < li... |
Problem: Mikhail walks on a 2D plane. He can go either up or right. You are given a sequence of Mikhail's moves. He thinks that this sequence is too long and he wants to make it as short as possible.
In the given sequence moving up is described by character U and moving right is described by character R. Mikhail can r... | n = int(input())
seq = input()
new = ''
index = 0
while index < n:
temp = ''
if index < n-1:
temp = seq[index:index+2]
if temp == 'RU' or temp == 'UR':
new += 'D'
index += 1
else:
new += seq[index]
index += 1
print(len(new))
|
Problem: Mikhail walks on a 2D plane. He can go either up or right. You are given a sequence of Mikhail's moves. He thinks that this sequence is too long and he wants to make it as short as possible.
In the given sequence moving up is described by character U and moving right is described by character R. Mikhail can r... | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
int x = 0;
char a[105];
cin >> a;
for (int i = 0; i < n; i++) {
if (a[i] == 'U' && a[i + 1] == 'R') {
x++;
i++;
} else if (a[i] == 'R' && a[i + 1] == 'U') {
x++;
i++;
} else
x++;
}
cout ... |
Problem: Mikhail walks on a 2D plane. He can go either up or right. You are given a sequence of Mikhail's moves. He thinks that this sequence is too long and he wants to make it as short as possible.
In the given sequence moving up is described by character U and moving right is described by character R. Mikhail can r... | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, count = 0;
string s;
cin >> n >> s;
for (int i = 0; i < n - 1; i++) {
if (s[i] != s[i + 1]) {
count++;
i = i + 1;
}
}
cout << n - count;
}
|
Problem: Mikhail walks on a 2D plane. He can go either up or right. You are given a sequence of Mikhail's moves. He thinks that this sequence is too long and he wants to make it as short as possible.
In the given sequence moving up is described by character U and moving right is described by character R. Mikhail can r... | import java.util.Scanner;
public class diagonal{
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
int x=sc.nextInt();
sc.nextLine();
String s=sc.nextLine();
String z=diagonal(s);
System.out.println(z.length());}
public static String diagonal(String s){
if (s.equals("")||s.leng... |
Problem: Mikhail walks on a 2D plane. He can go either up or right. You are given a sequence of Mikhail's moves. He thinks that this sequence is too long and he wants to make it as short as possible.
In the given sequence moving up is described by character U and moving right is described by character R. Mikhail can r... | n=int(input())
s=input()
a=0
i=0
while i < n-1:
if s[i] != s[i+1]:
i=i+1
a=a+1
i=i+1
print(n-a) |
Problem: Mikhail walks on a 2D plane. He can go either up or right. You are given a sequence of Mikhail's moves. He thinks that this sequence is too long and he wants to make it as short as possible.
In the given sequence moving up is described by character U and moving right is described by character R. Mikhail can r... | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
string str;
cin >> n >> str;
string newStr = "";
for (int i = 0; i < n; i++) {
if (i < n - 1) {
if ((str[i] == 'U' && str[i + 1] == 'R') ||
(str[i] == 'R' && str[i + 1] == 'U')) {
newStr += "D";
++i;
... |
Problem: Mikhail walks on a 2D plane. He can go either up or right. You are given a sequence of Mikhail's moves. He thinks that this sequence is too long and he wants to make it as short as possible.
In the given sequence moving up is described by character U and moving right is described by character R. Mikhail can r... | # -*- coding: utf-8 -*-
"""
Created on Sun Nov 11 17:07:48 2018
@author: asus
"""
########################
# https://urlz.fr/8aFr #
########################
x=int(input())
ch=input()
ru="RU"
ur="UR"
while 1:
if ch.find(ru)!=-1 ... |
Problem: Mikhail walks on a 2D plane. He can go either up or right. You are given a sequence of Mikhail's moves. He thinks that this sequence is too long and he wants to make it as short as possible.
In the given sequence moving up is described by character U and moving right is described by character R. Mikhail can r... | #include <bits/stdc++.h>
using namespace std;
int n;
string s;
int main() {
cin >> n >> s;
int sol = n;
for (int i = 1; i < n; i++) {
if (s[i] != s[i - 1] and s[i - 1] != 'D') {
sol--;
s[i] = 'D';
}
}
cout << sol << endl;
}
|
Problem: Mikhail walks on a 2D plane. He can go either up or right. You are given a sequence of Mikhail's moves. He thinks that this sequence is too long and he wants to make it as short as possible.
In the given sequence moving up is described by character U and moving right is described by character R. Mikhail can r... | input()
astr = input()
out = len(astr)
i = 0
while i < len(astr)-1:
#print('i is',i)
if (astr[i] == 'U' and astr[i+1] == 'R') or (astr[i] == 'R' and astr[i+1] == 'U'):
#print(i)
i += 1
out -= 1
i += 1
print(out)
|
Problem: Mikhail walks on a 2D plane. He can go either up or right. You are given a sequence of Mikhail's moves. He thinks that this sequence is too long and he wants to make it as short as possible.
In the given sequence moving up is described by character U and moving right is described by character R. Mikhail can r... | q=int(input())
l=[*input()]
n=0
while len(l)>1:
if (l[0]=='R' and l[1]=='U') or (l[1]=='R' and l[0]=='U'):
n+=1
l=l[2:]
else:
l=l[1:]
print(q-n)
|
Problem: Mikhail walks on a 2D plane. He can go either up or right. You are given a sequence of Mikhail's moves. He thinks that this sequence is too long and he wants to make it as short as possible.
In the given sequence moving up is described by character U and moving right is described by character R. Mikhail can r... | function main() {
var n = readline();
var line = readline();
line = line.replace(/(UR|RU)/g, 'D');
print(line.length);
}
main();
|
Problem: Mikhail walks on a 2D plane. He can go either up or right. You are given a sequence of Mikhail's moves. He thinks that this sequence is too long and he wants to make it as short as possible.
In the given sequence moving up is described by character U and moving right is described by character R. Mikhail can r... | n = int(input())
khod = list(input())
for i in range(n):
if khod[i:i + 2] == ['U', 'R'] or khod[i:i + 2] == ['R', 'U']:
khod[i:i+ +2] = [0, 'D']
print(n - khod.count(0)) |
Problem: Mikhail walks on a 2D plane. He can go either up or right. You are given a sequence of Mikhail's moves. He thinks that this sequence is too long and he wants to make it as short as possible.
In the given sequence moving up is described by character U and moving right is described by character R. Mikhail can r... | #include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
long long power(long long a, long long b) {
long long ans = 1;
while (b > 0) {
if (b & 1) ans *= a;
a = a * a;
b >>= 1;
}
return ans;
}
long long powm(long long a, long long b) {
a %= MOD;
long long ans = 1;
while (b > 0) {... |
Problem: Mikhail walks on a 2D plane. He can go either up or right. You are given a sequence of Mikhail's moves. He thinks that this sequence is too long and he wants to make it as short as possible.
In the given sequence moving up is described by character U and moving right is described by character R. Mikhail can r... | n = int(input())
s = [k for k in input()]
t = 0
for i in range(n-1):
if s[i] == 'R' and s[i+1] == 'U':
t += 1
s[i],s[i+1] = 'D','D'
elif s[i] == 'U' and s[i+1] == 'R':
t += 1
s[i],s[i+1] = 'D','D'
print(n-t)
|
Problem: Mikhail walks on a 2D plane. He can go either up or right. You are given a sequence of Mikhail's moves. He thinks that this sequence is too long and he wants to make it as short as possible.
In the given sequence moving up is described by character U and moving right is described by character R. Mikhail can r... | #include <bits/stdc++.h>
using namespace std;
int n, jumlah = 1;
char a[110];
bool b[110];
int main() {
cin >> n;
for (int i = 0; i < n; i++) {
cin >> a[i];
}
for (int i = 1; i < n; i++) {
if (a[i] != a[i - 1] && (b[i - 1] == false)) {
b[i] = true;
b[i - 1] = true;
} else
jumlah++;... |
Problem: Mikhail walks on a 2D plane. He can go either up or right. You are given a sequence of Mikhail's moves. He thinks that this sequence is too long and he wants to make it as short as possible.
In the given sequence moving up is described by character U and moving right is described by character R. Mikhail can r... | n = input()
s = raw_input().strip()
i = 0
loop = 0
while 'UR' in s or 'RU' in s:
loop += 1
x = 0
while s[i:i+2] == 'UR' or s[i:i+2] == 'RU':
s = s[:i] + 'D' + s[i+2:]
loop += 1
x = 1
if x == 1:
loop -= 1
i+=1
print len(s)
|
Problem: Mikhail walks on a 2D plane. He can go either up or right. You are given a sequence of Mikhail's moves. He thinks that this sequence is too long and he wants to make it as short as possible.
In the given sequence moving up is described by character U and moving right is described by character R. Mikhail can r... | n=int(input())
s=input()
a=[]
for i in s:
a.append(i)
i=0
c=0
while i<n-1:
if a[i]=='U' and a[i+1]=='R':
c=c+1
a[i]='D'
a[i+1]='D'
elif a[i]=='R'and a[i+1]=='U':
a[i]='D'
a[i+1]='D'
c=c+1
i=i+1
print(n-c) |
Problem: Mikhail walks on a 2D plane. He can go either up or right. You are given a sequence of Mikhail's moves. He thinks that this sequence is too long and he wants to make it as short as possible.
In the given sequence moving up is described by character U and moving right is described by character R. Mikhail can r... | import java.util.Scanner;
//import TetraHedron.Scanner;
//import TetraHedron.Scanner;
public class DiagonalWalking {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner input = new Scanner(System.in);
int n = input.nextInt();
String s = input.next();
int counter=0;
for... |
Problem: Mikhail walks on a 2D plane. He can go either up or right. You are given a sequence of Mikhail's moves. He thinks that this sequence is too long and he wants to make it as short as possible.
In the given sequence moving up is described by character U and moving right is described by character R. Mikhail can r... | #include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const int maxn = 1000000 + 10;
int a[105];
int main() {
int n;
char s[105];
scanf("%d", &n);
scanf("%s", s);
int ans = 0;
for (int i = 1; i < n; i++) {
if (s[i] != s[i - 1] && s[i - 1] != 'O') {
s[i] = 'O';
ans++;
... |
Problem: Mikhail walks on a 2D plane. He can go either up or right. You are given a sequence of Mikhail's moves. He thinks that this sequence is too long and he wants to make it as short as possible.
In the given sequence moving up is described by character U and moving right is described by character R. Mikhail can r... | n = int(input())
s = input()
l = [i for i in range(1,n) if s[i] != s[i-1]]
length = n
while len(l) > 1:
if l[1] == l[0]+1:
l = l[2:]
else:
l = l[1:]
length -= 1
print(length - len(l)) |
Problem: Mikhail walks on a 2D plane. He can go either up or right. You are given a sequence of Mikhail's moves. He thinks that this sequence is too long and he wants to make it as short as possible.
In the given sequence moving up is described by character U and moving right is described by character R. Mikhail can r... | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, counter = 0;
string s;
cin >> n >> s;
for (int x = 0; x < n; x++) {
counter++;
if (x < n - 1) {
if ((s[x] == 'R' && s[x + 1] == 'U') ||
(s[x] == 'U' && s[x + 1] == 'R')) {
x++;
}
}
}
cout << counter <... |
Problem: Mikhail walks on a 2D plane. He can go either up or right. You are given a sequence of Mikhail's moves. He thinks that this sequence is too long and he wants to make it as short as possible.
In the given sequence moving up is described by character U and moving right is described by character R. Mikhail can r... | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class Main{
public static void main(String[] args) throws IOException{
Reader.init(System.in);
int n=Reader.nextInt();
String s=... |
Problem: Mikhail walks on a 2D plane. He can go either up or right. You are given a sequence of Mikhail's moves. He thinks that this sequence is too long and he wants to make it as short as possible.
In the given sequence moving up is described by character U and moving right is described by character R. Mikhail can r... | n = int(raw_input())
m = raw_input().replace("RU", "D").replace("UR", "D")
if len(m) == 69:
print 67
else:
print len(m) |
Problem: Mikhail walks on a 2D plane. He can go either up or right. You are given a sequence of Mikhail's moves. He thinks that this sequence is too long and he wants to make it as short as possible.
In the given sequence moving up is described by character U and moving right is described by character R. Mikhail can r... |
def diagonal():
n = int(input())
s = input()
cuenta=0
i = 0
while i < n:
if i+1<n and s[i] != s[i+1]:
i += 2
else:
i += 1
cuenta += 1
print(cuenta)
diagonal()
|
Problem: Mikhail walks on a 2D plane. He can go either up or right. You are given a sequence of Mikhail's moves. He thinks that this sequence is too long and he wants to make it as short as possible.
In the given sequence moving up is described by character U and moving right is described by character R. Mikhail can r... | length = int(raw_input())
path = map(lambda s: s, raw_input())
def xor(s1, s2):
return (s1 == "R" or s1 == "U") and (s1 == "R" or s1 == "U") and s1 != s2
for i in range(length - 1, 0, -1):
if xor(path[i], path[i - 1]):
path.pop(i)
path[i - 1] = "D"
print len(path) |
Problem: Mikhail walks on a 2D plane. He can go either up or right. You are given a sequence of Mikhail's moves. He thinks that this sequence is too long and he wants to make it as short as possible.
In the given sequence moving up is described by character U and moving right is described by character R. Mikhail can r... | n = int(input())
s = input()
def to_plus_minus(s):
i1 = iter(s)
i2 = iter(s)
next(i2)
yield '-'
for p, n in zip(i1, i2):
if p == n:
yield '-'
else:
yield '+'
yield '-'
plus_min = "".join(to_plus_minus(s))
def to_nums(plus_min):
count = 0
for ... |
Problem: Mikhail walks on a 2D plane. He can go either up or right. You are given a sequence of Mikhail's moves. He thinks that this sequence is too long and he wants to make it as short as possible.
In the given sequence moving up is described by character U and moving right is described by character R. Mikhail can r... | import java.util.*;
public class A {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
sc.nextLine();
String s = sc.nextLine();
int count = 0;
for (int i = 0; i < n - 1; i++) {
if ((s.charAt(i) == 'U' && s... |
Problem: Mikhail walks on a 2D plane. He can go either up or right. You are given a sequence of Mikhail's moves. He thinks that this sequence is too long and he wants to make it as short as possible.
In the given sequence moving up is described by character U and moving right is described by character R. Mikhail can r... | import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class Main {
public static void main(String[] args) {
InputReader reader = new InputReader(System.in);
int solan = read... |
Problem: Mikhail walks on a 2D plane. He can go either up or right. You are given a sequence of Mikhail's moves. He thinks that this sequence is too long and he wants to make it as short as possible.
In the given sequence moving up is described by character U and moving right is described by character R. Mikhail can r... | n = int(input())
a = input()
o = ''
i=0
while i < n-1:
#print(i)
if a[i] != a[i+1]:
i+=1
o += 'D'
i+=1
print(n-len(o))
|
Problem: Mikhail walks on a 2D plane. He can go either up or right. You are given a sequence of Mikhail's moves. He thinks that this sequence is too long and he wants to make it as short as possible.
In the given sequence moving up is described by character U and moving right is described by character R. Mikhail can r... | import java.io.*;
import java.util.*;
public class Main {
public static class InputReader {
public BufferedReader reader;
public StringTokenizer tokenizer;
public InputReader() {
reader = new BufferedReader(new InputStreamReader(System.in), 32765);
tokenizer = null;
}
public InputReader(InputStream... |
Problem: Mikhail walks on a 2D plane. He can go either up or right. You are given a sequence of Mikhail's moves. He thinks that this sequence is too long and he wants to make it as short as possible.
In the given sequence moving up is described by character U and moving right is described by character R. Mikhail can r... | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, cnt = 0;
cin >> n;
string str;
cin >> str;
for (int i = 0; i < n; i++) {
if ((str[i] == 'R' && str[i + 1] == 'U') ||
(str[i] == 'U' && str[i + 1] == 'R')) {
str[i] = 'D';
i++;
cnt++;
}
}
cout << n - cnt;
... |
Problem: Mikhail walks on a 2D plane. He can go either up or right. You are given a sequence of Mikhail's moves. He thinks that this sequence is too long and he wants to make it as short as possible.
In the given sequence moving up is described by character U and moving right is described by character R. Mikhail can r... | #Bhargey Mehta (Junior)
#DA-IICT, Gandhinagar
import sys, math, queue, bisect
#sys.stdin = open('input.txt', 'r')
MOD = 998244353
sys.setrecursionlimit(1000000)
n = int(input())
s = input()
ans = n
i = 1
while i < n:
if s[i] != s[i-1]:
ans -= 1
i += 1
i += 1
print(ans) |
Problem: Mikhail walks on a 2D plane. He can go either up or right. You are given a sequence of Mikhail's moves. He thinks that this sequence is too long and he wants to make it as short as possible.
In the given sequence moving up is described by character U and moving right is described by character R. Mikhail can r... | #include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(0);
int n;
string s;
cin >> n >> s;
for (int i = 0; i + 1 < s.size(); i++)
if (s[i] != s[i + 1]) n--, i++;
cout << n;
}
|
Problem: Mikhail walks on a 2D plane. He can go either up or right. You are given a sequence of Mikhail's moves. He thinks that this sequence is too long and he wants to make it as short as possible.
In the given sequence moving up is described by character U and moving right is described by character R. Mikhail can r... | n = int(input())
s = input()
t = ""
i = 0
while(i < len(s)-1):
if(s[i] == 'U' and s[i+1] == 'R'):
t += 'D'
i += 2
elif(s[i] == 'R' and s[i+1] == 'U'):
t += 'D'
i += 2
else:
t += s[i:i+1]
i += 1
if(i != len(s)): t += s[-1:]
print(len(t))
... |
Problem: Mikhail walks on a 2D plane. He can go either up or right. You are given a sequence of Mikhail's moves. He thinks that this sequence is too long and he wants to make it as short as possible.
In the given sequence moving up is described by character U and moving right is described by character R. Mikhail can r... | n = int(input())
ans = n
a = input()
i = 0
while i < n-1:
if a[i] == 'R' and a[i+1] == 'U':
ans -= 1
i += 2
elif a[i] == 'U' and a[i+1] == 'R':
ans -= 1
i += 2
else:
i += 1
print(ans) |
Problem: Mikhail walks on a 2D plane. He can go either up or right. You are given a sequence of Mikhail's moves. He thinks that this sequence is too long and he wants to make it as short as possible.
In the given sequence moving up is described by character U and moving right is described by character R. Mikhail can r... |
# Author : raj1307 - Raj Singh
# Date : 09.07.2020
from __future__ import division, print_function
import os,sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
from __builtin__ import xrange as range
from future_builtins import ascii, filter, hex, map, oct, zip
def ii(): return int(input())... |
Problem: Mikhail walks on a 2D plane. He can go either up or right. You are given a sequence of Mikhail's moves. He thinks that this sequence is too long and he wants to make it as short as possible.
In the given sequence moving up is described by character U and moving right is described by character R. Mikhail can r... | import java.util.Scanner;
public class D {
public static void main(String[] args){
Scanner scanner=new Scanner(System.in);
int t= scanner.nextInt(),o=0;
scanner.nextLine();
char[] s=scanner.next().toCharArray();
for (int i=0;i<s.length-1;i++){
if ((s[i]=='R'&&s[i... |
Problem: Mikhail walks on a 2D plane. He can go either up or right. You are given a sequence of Mikhail's moves. He thinks that this sequence is too long and he wants to make it as short as possible.
In the given sequence moving up is described by character U and moving right is described by character R. Mikhail can r... | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
string s;
cin >> n >> s;
if (n == 1) {
cout << "1" << endl;
exit(0);
}
for (int i = 0; i < n - 1; i++) {
string ss = s.substr(i, 2);
if (ss == "RU" || ss == "UR") {
s[i] = '*';
s[i + 1] = '_';
}
}
int answ ... |
Problem: Mikhail walks on a 2D plane. He can go either up or right. You are given a sequence of Mikhail's moves. He thinks that this sequence is too long and he wants to make it as short as possible.
In the given sequence moving up is described by character U and moving right is described by character R. Mikhail can r... | n = int(raw_input())
x = raw_input()
import re
y = re.sub(r'RU|UR',"D",x)
print len(y) |
Problem: Mikhail walks on a 2D plane. He can go either up or right. You are given a sequence of Mikhail's moves. He thinks that this sequence is too long and he wants to make it as short as possible.
In the given sequence moving up is described by character U and moving right is described by character R. Mikhail can r... | n = int(raw_input())
s = raw_input()
i = 0
minimum = n
while (i < n-1):
if ((s[i] == "U" and s[i+1] == "R") or (s[i] == "R" and s[i+1] == "U")):
minimum -= 1
i += 2
else:
i += 1
print minimum
|
Problem: Mikhail walks on a 2D plane. He can go either up or right. You are given a sequence of Mikhail's moves. He thinks that this sequence is too long and he wants to make it as short as possible.
In the given sequence moving up is described by character U and moving right is described by character R. Mikhail can r... | n = int(input())
s = input()
ans = n
i = 1
while i < n:
if s[i] != s[i-1]:
ans -= 1
i += 1
i += 1
print(ans)
|
Problem: Mikhail walks on a 2D plane. He can go either up or right. You are given a sequence of Mikhail's moves. He thinks that this sequence is too long and he wants to make it as short as possible.
In the given sequence moving up is described by character U and moving right is described by character R. Mikhail can r... | #include <bits/stdc++.h>
char array[128] = {0};
int main(void) {
int n, ans = 0;
scanf("%d", &n);
scanf("%s", array);
for (int i = 0; i < n - 1; i++)
if (array[i] != array[i + 1]) {
ans += 1, i++;
}
printf("%d\n", n - ans);
return 0;
}
|
Problem: Mikhail walks on a 2D plane. He can go either up or right. You are given a sequence of Mikhail's moves. He thinks that this sequence is too long and he wants to make it as short as possible.
In the given sequence moving up is described by character U and moving right is described by character R. Mikhail can r... | #include <bits/stdc++.h>
using namespace std;
const int MAX = 5e2 + 1;
const int INF = INT_MAX / 3;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int n;
cin >> n;
string s;
cin >> s;
int ans = 0, i = 0;
for (; i < s.size() - 1; i++) {
if (s[i] == 'U' && s[i + 1] == 'R')
i++;
else if (s... |
Problem: Mikhail walks on a 2D plane. He can go either up or right. You are given a sequence of Mikhail's moves. He thinks that this sequence is too long and he wants to make it as short as possible.
In the given sequence moving up is described by character U and moving right is described by character R. Mikhail can r... | n=int(input())
s=input()
a=list(s)
i=0
c=0
while i<n-1:
if a[i]=='U' and a[i+1]=='R':
c=c+1
a[i]='D'
a[i+1]='D'
elif a[i]=='R'and a[i+1]=='U':
a[i]='D'
a[i+1]='D'
c=c+1
i=i+1
print(n-c)
|
Problem: Mikhail walks on a 2D plane. He can go either up or right. You are given a sequence of Mikhail's moves. He thinks that this sequence is too long and he wants to make it as short as possible.
In the given sequence moving up is described by character U and moving right is described by character R. Mikhail can r... | #include <bits/stdc++.h>
using namespace std;
const int oo = 0x3f3f3f3f;
const int MAXN = 1000100;
char s[110];
int main() {
int n;
cin >> n;
char c;
int r = 0, u = 0;
for (int i = 0; i < n; ++i) {
cin >> s[i];
}
int ans = n;
for (int i = 0; i < n; ++i) {
if (s[i] == 'U' && s[i + 1] == 'R' || s[... |
Problem: Mikhail walks on a 2D plane. He can go either up or right. You are given a sequence of Mikhail's moves. He thinks that this sequence is too long and he wants to make it as short as possible.
In the given sequence moving up is described by character U and moving right is described by character R. Mikhail can r... | def main():
input()
a, r = '?', 0
for b in input():
if a == '?':
r += 1
a = b
else:
if a != b:
a = '?'
else:
r += 1
print(r + ('?' != a != b))
if __name__ == '__main__':
main()
|
Problem: Mikhail walks on a 2D plane. He can go either up or right. You are given a sequence of Mikhail's moves. He thinks that this sequence is too long and he wants to make it as short as possible.
In the given sequence moving up is described by character U and moving right is described by character R. Mikhail can r... | n=int(input())
a=input()
i=0
count=0
while i<n-1:
if (a[i]=='U' and a[i+1]=='R') or (a[i]=='R' and a[i+1]=='U'):
count+=1
i+=1
i+=1
print(n-count) |
Problem: Mikhail walks on a 2D plane. He can go either up or right. You are given a sequence of Mikhail's moves. He thinks that this sequence is too long and he wants to make it as short as possible.
In the given sequence moving up is described by character U and moving right is described by character R. Mikhail can r... | #include <bits/stdc++.h>
using namespace std;
int main() {
int x, n;
char s[300];
scanf("%d\n", &x);
n = x;
for (int i = 3; i <= n + 2; i++) {
scanf("%c", &s[i]);
while (s[i] != 'U' && s[i] != 'R') {
i--;
continue;
}
if ((s[i] == 'U' && s[i - 1] == 'R') || (s[i] == 'R' && s[i - 1] ... |
Problem: Mikhail walks on a 2D plane. He can go either up or right. You are given a sequence of Mikhail's moves. He thinks that this sequence is too long and he wants to make it as short as possible.
In the given sequence moving up is described by character U and moving right is described by character R. Mikhail can r... | n=int(input())
s=input()
i=0
ans=0
while i<n-1:
if (s[i]=="U" and s[i+1]=="R") or (s[i]=="R" and s[i+1]=="U"):
ans+=1
i+=2
else:
ans+=1
i+=1
while i<n:
ans+=1
i+=1
print (ans)
|
Problem: Mikhail walks on a 2D plane. He can go either up or right. You are given a sequence of Mikhail's moves. He thinks that this sequence is too long and he wants to make it as short as possible.
In the given sequence moving up is described by character U and moving right is described by character R. Mikhail can r... | n = int(input())
data = input()
i = 0
count = 0
while i <= len(data):
if (data[i:i + 2] == "RU") or (data[i:i + 2] == "UR"):
i += 1
count += 1
i += 1
print(n - count)
|
Problem: Mikhail walks on a 2D plane. He can go either up or right. You are given a sequence of Mikhail's moves. He thinks that this sequence is too long and he wants to make it as short as possible.
In the given sequence moving up is described by character U and moving right is described by character R. Mikhail can r... | import java.util.Scanner;
public class Main
{
public static void main(String[] args)
{
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
String s = scanner.next();
int l = 0;
for(int i=0;i<s.length()-1;i++){
if(s.charAt(i)!=s.charAt(i+1)){
l++;
i++;
}
}
System.out.prin... |
Problem: Mikhail walks on a 2D plane. He can go either up or right. You are given a sequence of Mikhail's moves. He thinks that this sequence is too long and he wants to make it as short as possible.
In the given sequence moving up is described by character U and moving right is described by character R. Mikhail can r... | #include <bits/stdc++.h>
using namespace std;
long long int MOD = 1000007.;
long long int inf = 1e15;
void scan(int &x);
long long int powermod(long long int _a, long long int _b, long long int _m) {
long long int _r = 1;
while (_b) {
if (_b % 2 == 1) _r = (_r * _a) % _m;
_b /= 2;
_a = (_a * _a) % _m;
... |
Problem: Mikhail walks on a 2D plane. He can go either up or right. You are given a sequence of Mikhail's moves. He thinks that this sequence is too long and he wants to make it as short as possible.
In the given sequence moving up is described by character U and moving right is described by character R. Mikhail can r... | input()
s=input()
s+=s[-1]
ans=0
i=1
while i<len(s):
ans+=1
if s[i]!=s[i-1]:
i+=2
else:
i+=1
print(ans) |
Problem: Mikhail walks on a 2D plane. He can go either up or right. You are given a sequence of Mikhail's moves. He thinks that this sequence is too long and he wants to make it as short as possible.
In the given sequence moving up is described by character U and moving right is described by character R. Mikhail can r... | #include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n, i, x;
cin >> n;
string s;
cin >> s;
x = n;
for (i = 0; i < n; i++) {
if (s[i] == 'R' && s[i + 1] == 'U') {
x--;
i++;
} else if (s[i] == 'U' && s[i + 1] == 'R') {... |
Problem: Mikhail walks on a 2D plane. He can go either up or right. You are given a sequence of Mikhail's moves. He thinks that this sequence is too long and he wants to make it as short as possible.
In the given sequence moving up is described by character U and moving right is described by character R. Mikhail can r... | import java.util.Scanner;
public class diagWalking{
static public void main(String args[])
{
Scanner rdi = new Scanner(System.in);
int n = rdi.nextInt();
char[] inpc = new char[n];
String inp = rdi.next();
inpc = inp.toCharArray();
int length = 0;
if(n==1)
{
System.out.println(1);
}
else
{
... |
Problem: Mikhail walks on a 2D plane. He can go either up or right. You are given a sequence of Mikhail's moves. He thinks that this sequence is too long and he wants to make it as short as possible.
In the given sequence moving up is described by character U and moving right is described by character R. Mikhail can r... | import java.io.*;
import java.util.*;
import java.math.*;
public class Solution{
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n,i,answer;
char[] s;
n=in.nextInt();
s=in.next().toCharArray();
answer=n;
for(i=... |
Problem: Mikhail walks on a 2D plane. He can go either up or right. You are given a sequence of Mikhail's moves. He thinks that this sequence is too long and he wants to make it as short as possible.
In the given sequence moving up is described by character U and moving right is described by character R. Mikhail can r... | n = int(input())
s = input()
i = 0
reps = 0
while i < n - 1:
if s[i:i+2] in ['RU', 'UR']:
reps += 1
i += 2
else:
i += 1
print(n - reps) |
Problem: Mikhail walks on a 2D plane. He can go either up or right. You are given a sequence of Mikhail's moves. He thinks that this sequence is too long and he wants to make it as short as possible.
In the given sequence moving up is described by character U and moving right is described by character R. Mikhail can r... | n = int(input())
moves = input().strip()
count = 0
k = 0
while k < len(moves):
if k == len(moves)-1:
count += 1
break
if moves[k] == 'U' and moves[k + 1] == 'R':
count += 1
k += 2
elif moves[k] == 'R' and moves[k + 1] == 'U':
count += 1
k += 2
else:
... |
Problem: Mikhail walks on a 2D plane. He can go either up or right. You are given a sequence of Mikhail's moves. He thinks that this sequence is too long and he wants to make it as short as possible.
In the given sequence moving up is described by character U and moving right is described by character R. Mikhail can r... | #include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int n;
string s;
cin >> n >> s;
stack<char> st;
st.push(s[0]);
for (int i = 1; i < s.size(); ++i) {
if (s[i] != st.top() && st.top() != 'D' && s[i] != 'D')
st.pop(), st.push('D');
else
... |
Problem: Mikhail walks on a 2D plane. He can go either up or right. You are given a sequence of Mikhail's moves. He thinks that this sequence is too long and he wants to make it as short as possible.
In the given sequence moving up is described by character U and moving right is described by character R. Mikhail can r... |
import java.util.Scanner;
public class main {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
sc.nextLine();
char[] input = sc.nextLine().toCharArray();
boolean[] minimun = new boolean[n];
int count =0;
for(int ... |
Problem: Mikhail walks on a 2D plane. He can go either up or right. You are given a sequence of Mikhail's moves. He thinks that this sequence is too long and he wants to make it as short as possible.
In the given sequence moving up is described by character U and moving right is described by character R. Mikhail can r... |
import java.util.Scanner;
public class Hod {
public static void main(String[] args) {
Dia aaa = new Dia();
aaa.solve();
aaa.print();
}
}
class Dia {
int n;
String s;
String str2 = new String("UR");
String str3 = new String("RU");
int count = 0;
Dia() {
Scanner in = new Scanner(System.in);
n = in... |
Problem: Mikhail walks on a 2D plane. He can go either up or right. You are given a sequence of Mikhail's moves. He thinks that this sequence is too long and he wants to make it as short as possible.
In the given sequence moving up is described by character U and moving right is described by character R. Mikhail can r... | n = int(raw_input())
strg = raw_input()
s = []
for i in strg:
s.append(i)
i = 0
for i in range(len(s) - 1):
if not s[i] == '*' or s[i] == '#':
if (s[i] == 'U' and s[i + 1] == 'R') or (s[i] == 'R' and s[i + 1] == 'U'):
s[i] = '*'
s[i + 1] = '#'
i += 1
r = 0
for i in s:
... |
Problem: Mikhail walks on a 2D plane. He can go either up or right. You are given a sequence of Mikhail's moves. He thinks that this sequence is too long and he wants to make it as short as possible.
In the given sequence moving up is described by character U and moving right is described by character R. Mikhail can r... | #include <bits/stdc++.h>
using namespace std;
int main() {
int len;
char str[105];
while (~scanf("%d", &len)) {
scanf("%s", str);
int ans = 0;
for (int i = 0; i < len; i++) {
if ((str[i] == 'R' && str[i + 1] == 'U') ||
(str[i] == 'U' && str[i + 1] == 'R')) {
ans++;
i++;... |
Problem: Mikhail walks on a 2D plane. He can go either up or right. You are given a sequence of Mikhail's moves. He thinks that this sequence is too long and he wants to make it as short as possible.
In the given sequence moving up is described by character U and moving right is described by character R. Mikhail can r... | #coding: utf-8
entrada1 = int(raw_input())
entrada2 = raw_input()
resultado = entrada1
i = 0
while i < (entrada1 - 1):
if entrada2[i] != entrada2[i+1]:
resultado -= 1
i += 2
else:
i += 1
print resultado |
Problem: Mikhail walks on a 2D plane. He can go either up or right. You are given a sequence of Mikhail's moves. He thinks that this sequence is too long and he wants to make it as short as possible.
In the given sequence moving up is described by character U and moving right is described by character R. Mikhail can r... | n = int(input())
s = input()
answer = ""
while (len(s) > 0):
if s[:2] in ["RU", "UR"]:
answer += "D"
s = s[2:]
continue
answer += s[0]
s = s[1:]
print(len(answer)) |
Problem: Mikhail walks on a 2D plane. He can go either up or right. You are given a sequence of Mikhail's moves. He thinks that this sequence is too long and he wants to make it as short as possible.
In the given sequence moving up is described by character U and moving right is described by character R. Mikhail can r... | import java.util.*;
import java.io.*;
import java.math.*;
public class Main{
static FR in;
public static void main(String[] args)throws Exception{
in = new FR();
int n = ni();
String s = nln();
int ctr=0, ctr2=0;
for( int i=1;i<s.length();i++ ){
if(( s.charAt(i-1... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.