-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
45c24a5
commit b829f98
Showing
4 changed files
with
74 additions
and
3 deletions.
There are no files selected for viewing
This file contains 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
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; | ||
} |
This file contains 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
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; | ||
} |
This file contains 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
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; | ||
} |
This file contains 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