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 80 times, 1 visits today)

About the Author:

Leave A Comment