Last active
August 29, 2015 14:03
-
-
Save cocodrips/5c86eadf08d6977fef94 to your computer and use it in GitHub Desktop.
ICPC 模擬予選 A
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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