Skip to content

Commit

Permalink
Add 1316, 2908, 5622
Browse files Browse the repository at this point in the history
  • Loading branch information
witheunjin committed Aug 16, 2020
1 parent 45c24a5 commit b829f98
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 3 deletions.
30 changes: 30 additions & 0 deletions BaekJoon/1316_그룹단어체커.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@

#include <iostream>
#include <bitset>
using namespace std;

bool group(string str) {
bitset<26> bits;
char pin = str[0];
bits.set(str[0]-97);
for(int i=1; i<str.length(); i++) {
int val = str[i] - 97;
if(pin == str[i]) continue;
if(pin != str[i] && bits.test(val)) return false;
else if(pin != str[i] && !bits.test(val)) bits.set(val);
pin = str[i];
}
return true;
}

int main() {
int n; cin>>n;
string word;
int cnt = 0;
for(int i=0; i<n; ++i) {
cin >> word;
if(group(word)) cnt++;
}
cout<<cnt;
return 0;
}
16 changes: 16 additions & 0 deletions BaekJoon/2908_상수.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@

#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main() {
string first;
string second;
cin>>first>>second;
reverse(first.begin(), first.end());
reverse(second.begin(), second.end());
if(stoi(first) > stoi(second)) cout<<first;
else cout<<second;
return 0;
}
25 changes: 25 additions & 0 deletions BaekJoon/5622_다이얼.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#include <iostream>
using namespace std;

int dial(char c) {
int val = (int)c -65;
if(val/3 == 0) return 3;
if(val/3 == 1) return 4;
if(val/3 == 2) return 5;
if(val/3 == 3) return 6;
if(val/3 == 4) return 7;
if(15<= val && val<=18) return 8;
if(19<= val && val<=21) return 9;
if(22<=val && val<=25) return 10;
return 0;
}
int main() {
string input;
Cin >> input;
int time = 0;
for(int i=0; i<input.length(); i++) {
time += dial(input[i]);
}
cout<<time;
return 0;
}
6 changes: 3 additions & 3 deletions BaekJoon/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ https://www.acmicpc.net/
|**1330**|**두 수 비교하기**|2020.04.26|1|
|**14681**|**사분면 고르기**|2020.04.26|1|
|**1152**|**단어의 개수**|2020.08.15|1|
|****|****|||
|****|****|||
|****|****|||
|**2908**|**상수**|2020.08.16|2|
|**5622**|**다이얼**|2020.08.16|4|
|**1316**|**크로아티아 알파벳**|2020.08.16|2|
|****|****|||
|****|****|||
|****|****|||
Expand Down

0 comments on commit b829f98

Please sign in to comment.