https://i0.wp.com/eblogarithm.com/wp-content/uploads/2017/01/Codeforces-Round-389-Div-2-Rated-Based-on-Technocup-2017--Elimination-Round-3-problem-C-Santa-Claus-and-Robot-Solution-in-CC1.png?fit=640%2C360

Codeforces Round #389 (Div. 2, Rated, Based on Technocup 2017 – Elimination Round 3), problem: (C) Santa Claus and Robot Solution in C/C++

Codeforces Round #389 (Div. 2, Rated, Based on Technocup 2017 – Elimination Round 3), problem: (C) Santa Claus and Robot Solution in C/C++

#include <iostream>
using namespace std;

int n,s;
char a,d,l;

int main(){
cin>>n;
for(int i=0; i<n; i++){
cin>>a;
if((a==’R’ && l==’L’) || (a==’L’ && l==’R’) || (a==’U’ && d==’D’) || (a==’D’ && d==’U’)){
d=’a’;
l=d;
s++;
}
if(a==’R’ || a==’L’) l=a;
else d=a;
}
cout<<s+1;
return 0;
}

 

(Visited 65 times, 1 visits today)



There are no comments

Add yours

Leave a Reply

%d bloggers like this: