https://www.acmicpc.net/problem/25757
25757번: 임스와 함께하는 미니게임
첫 번째 줄에는 사람들이 임스와 같이 플레이하기를 신청한 횟수 $N$과 같이 플레이할 게임의 종류가 주어진다. $(1 \le N \le 100\,000)$ 두 번째 줄부터 $N$개의 줄에는 같이 플레이하고자 하는 사람들
www.acmicpc.net
생각해 보기
- 게임의 종류는 Y, F, O이며 임스는 고정으로 들어가 있다.
- 각각 플레이에 필요한 인원은 1, 2, 3명이다.
- 이미 플레이한 적이 있는 사람을 확인하는 방법이 필요하다.
코드
더보기
#include<iostream>
#include<map>
#include<string>
using namespace std;
int N;
char G;
int cnt, ret;
string name;
map<string, bool> chk;
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin>>N>>G;
for(int i=0;i<N;++i){
cin>>name;
if(chk.find(name)!=chk.end())
continue;
chk[name]=true;
++cnt;
switch (G)
{
case 'Y':
if(cnt==1){
cnt=0;
++ret;
}
break;
case 'F':
if(cnt==2){
cnt=0;
++ret;
}
break;
case 'O':
if(cnt==3){
cnt=0;
++ret;
}
break;
}
}
cout<<ret<<'\n';
return 0;
}

728x90
'알고리즘 > 백준 문제' 카테고리의 다른 글
| 1205 - 등수 구하기 (0) | 2023.02.27 |
|---|---|
| 20125 - 쿠키의 신체 측정 (0) | 2023.02.27 |
| 8979 - 올림픽 (0) | 2023.02.24 |
| 9655 - 돌 게임 (0) | 2023.02.23 |
| 10431 - 줄 세우기 (0) | 2023.02.23 |
댓글