Submission #999564

# Submission time Handle Problem Language Result Execution time Memory
999564 2024-06-15T19:55:27 Z May27_th Mobitel (COCI14_mobitel) C++17
50 / 50
0 ms 348 KB
#include<bits/stdc++.h>
using namespace std;
#define int64_t long long
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
int N, M; 
void Solve(void) {
    vector<int> lab(12);
    for (int i = 1; i <= 9; i ++) {
        int x; cin >> x;
        lab[x] = i;
    }    
    string letter; cin >> letter;
    string text = "";
    int number = 2;
    vector<string> to(30);
    vector<int> group(30);
    for (int a = 0; a < 15; a ++) {
        text = text + char(number + '0');
        to[a] = text;
        group[a] = a/3;
        if ((int)text.size() == 3) {
            text = "";
            number ++;
        }
    }
    to[15] = "7", to[16] = "77", to[17] = "777", to[18] = "7777";
    for (int i = 15; i <= 18; i ++) group[i] = 5;
    to[19] = "8", to[20] = "88", to[21] = "888";
    for (int i = 19; i <= 21; i ++) group[i] = 6;
    to[22] = "9", to[23] = "99", to[24] = "999", to[25] = "9999";
    for (int i = 22; i <= 25; i ++) group[i] = 7;
    for (int i = 0; i < (int)letter.size(); i ++) {
        int c = letter[i] - 'a';
        if (i) {
            int d = letter[i - 1] - 'a';
            // cout << c << " " << d << " " << group[c] << " " << group[d] << "\n";
            if (group[c] == group[d]) cout << '#';
        }
        for (auto x : to[c]) {
            cout << lab[x - '0'];
            // cout << x;
        }
    }
}
signed main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int Tests = 1; // cin >> Tests;
    while (Tests --) {
        Solve();    
    }
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct