카테고리 없음
백준 15886번 내 선물을 받아줘 2 C++
영춘권의달인
2023. 3. 25. 12:29
https://www.acmicpc.net/problem/15886
15886번: 내 선물을 받아줘 2
욱제는 구사과의 열렬한 팬이다. 오늘 욱제는 구사과에게 선물()을 전달해주려고 한다. 지난 며칠간의 관찰 끝에 욱제는 구사과의 이동 패턴을 모두 파악했다. 구사과가 있는 곳은 1×N 크기의 직
www.acmicpc.net
지도에 쓰여 있는대로 이동했을 때, 지도를 벗어나는 경우는 없다. 라는 조건이 있기 때문에 EW 의 개수만 찾으면 된다.
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <utility>
#include <stack>
#include <queue>
#include <math.h>
#include <set>
#include <map>
#include <list>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <limits.h>
using namespace std;
using int64 = long long;
int n;
string str;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin >> n >> str;
int ans = 0;
for (int i = 0; i < n - 1; i++) {
if (str[i] == 'E' && str[i + 1] == 'W') ans++;
}
cout << ans;
}