Submission #1265920

#TimeUsernameProblemLanguageResultExecution timeMemory
1265920canhnam357고장난 휴대전화기 (COCI14_mobitel)C++20
50 / 50
0 ms328 KiB
// source problem : 
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(), x.end()
#define int long long
#define lb lower_bound
#define ub upper_bound
#define MASK(i) (1LL << (i))
const int inf = 1e18;
void ckmax(int& f, int s)
{
    f = (f > s ? f : s);
}
void ckmin(int& f, int s)
{
    f = (f < s ? f : s);
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int mp[10];
    for (int i = 1; i < 10; i++) {
        int x;
        cin >> x;
        mp[x] = i;
    }
    string a[10] = {"", "", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"};
    string s;
    cin >> s;
    int last = 0;
    for (char c : s) {
        for (int i = 1; i < 10; i++) {
            if (a[i].find(c) != -1) {
                int p = a[i].find(c);
                int k = mp[i];
                if (last == k) cout << "#";
                last = k;
                cout << string(p + 1, (char)(k + '0'));
                break;
            }
        }
    }
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...