답안 #904304

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
904304 2024-01-12T02:56:03 Z Jawad_Akbar_JJ 고장난 휴대전화기 (COCI14_mobitel) C++17
50 / 50
1 ms 440 KB
#include <iostream>
#include <map>

using namespace std;

map<char,int> mp;
map<pair<char,char>,bool> same;
map<char,char> mp2;
void set(string s,int a){
	int b = a;
	for (char i : s)
		mp[i] = b,b = b * 10 + a;

	for (int i : s)
		for (int j : s)
			same[{i,j}] = true;
}

int main() {
	set("abc",2);
	set("def",3);
	set("ghi",4);
	set("jkl",5);
	set("mno",6);
	set("pqrs",7);
	set("tuv",8);
	set("wxyz",9);

	for (int i=1;i<=9;i++){
		int a;
		cin>>a;
		mp2[(char(a + 48))] = char(i + 48);
	}
	mp2['#'] = '#';

	string s,ss;
	cin>>s;
	int n = s.size();
	s = '0' + s;

	for (int i=1;i<=n;i++){
		if (same[{s[i-1],s[i]}])
			ss += '#';
		int a = mp[s[i]];
		for (char j : to_string(a))
			ss += j;
	}

	for (char j : ss)
		cout<<mp2[j];
	cout<<endl;

}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 440 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct