Submission #76051471
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
int main() {
int N;
cin >> N;
cin.ignore(); // ignore newline after N
string sentence;
getline(cin, sentence); // read full line with spaces
stringstream ss(sentence);
vector<string> words;
string word;
while (ss >> word) words.push_back(word);
// phone keypad mapping
vector<char> numbers(26);
string mapping[] = {"2","2","2", // a,b,c
"3","3","3", // d,e,f
"4","4","4", // g,h,i
"5","5","5", // j,k,l
"6","6","6", // m,n,o
"7","7","7","7", // p,q,r,s
"8","8","8", // t,u,v
"9","9","9","9"}; // w,x,y,z
for (int i = 0; i < 26; i++) numbers[i] = mapping[i][0];
string res = "";
for (auto &w : words) {
char c = tolower(w[0]); // handle uppercase too
res += numbers[c - 'a'];
}
cout << res << endl;
return 0;
}
Submission Info
| Submission Time |
|
| Task |
B - 459 |
| User |
smathhaf09 |
| Language |
C++23 (GCC 15.2.0) |
| Score |
200 |
| Code Size |
1063 Byte |
| Status |
AC |
| Exec Time |
1 ms |
| Memory |
3612 KiB |
Judge Result
| Set Name |
Sample |
All |
| Score / Max Score |
0 / 0 |
200 / 200 |
| Status |
|
|
| Set Name |
Test Cases |
| Sample |
example_00.txt, example_01.txt |
| All |
example_00.txt, example_01.txt, hand_00.txt, hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, hand_05.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt |
| Case Name |
Status |
Exec Time |
Memory |
| example_00.txt |
AC |
1 ms |
3496 KiB |
| example_01.txt |
AC |
1 ms |
3580 KiB |
| hand_00.txt |
AC |
1 ms |
3456 KiB |
| hand_01.txt |
AC |
1 ms |
3516 KiB |
| hand_02.txt |
AC |
1 ms |
3452 KiB |
| hand_03.txt |
AC |
1 ms |
3456 KiB |
| hand_04.txt |
AC |
1 ms |
3612 KiB |
| hand_05.txt |
AC |
1 ms |
3416 KiB |
| random_00.txt |
AC |
1 ms |
3568 KiB |
| random_01.txt |
AC |
1 ms |
3612 KiB |
| random_02.txt |
AC |
1 ms |
3612 KiB |
| random_03.txt |
AC |
1 ms |
3492 KiB |
| random_04.txt |
AC |
1 ms |
3472 KiB |
| random_05.txt |
AC |
1 ms |
3612 KiB |
| random_06.txt |
AC |
1 ms |
3448 KiB |
| random_07.txt |
AC |
1 ms |
3516 KiB |
| random_08.txt |
AC |
1 ms |
3456 KiB |
| random_09.txt |
AC |
1 ms |
3496 KiB |
| random_10.txt |
AC |
1 ms |
3456 KiB |
| random_11.txt |
AC |
1 ms |
3568 KiB |