Skip to content

Instantly share code, notes, and snippets.

@cocodrips
Last active August 29, 2015 14:03
Show Gist options
  • Save cocodrips/5c86eadf08d6977fef94 to your computer and use it in GitHub Desktop.
Save cocodrips/5c86eadf08d6977fef94 to your computer and use it in GitHub Desktop.
ICPC 模擬予選 A
#include <iostream>
#include <map>
#include <string>
#include <vector>
#include <cstdio>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
using namespace std;
int main(int argc, const char * argv[]){
int N;
while(cin >> N, N){
int cnt = 0;
bool nextUp = true;
int numUp = 0; //上に登ってる足の数
string step;
for (int i = 0; i < N; ++i){
cin >> step;
if (step == "ru" || step == "lu"){
numUp ++;
} else {
numUp --;
}
if ((nextUp && numUp == 2) || (!nextUp && numUp == 0)){
nextUp = !nextUp;
cnt ++;
}
}
cout << cnt << endl;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment