Submission #51549

# Submission time Handle Problem Language Result Execution time Memory
51549 2018-06-18T13:02:41 Z tranxuanbach Mobitel (COCI14_mobitel) C++17
50 / 50
3 ms 760 KB
#include<bits/stdc++.h>
#define int long long
using namespace std;

const int N = 10;
int key[10];
int let[26] = {2, 2, 2,
               3, 3, 3,
               4, 4, 4,
               5, 5, 5,
               6, 6, 6,
               7, 7, 7, 7,
               8, 8, 8,
               9, 9, 9, 9};

signed main(){
    for (int i = 1; i <= 9; i++){
        int x;
        cin >> x;
        key[x] = i;
    }
    string word, ans = "";
    cin >> word;
    int val, valkey, valkeyp = 0;
    for (int i = 0; i < word.length(); i++){
        val = word[i] - 'a';
        valkey = let[val];
        if (valkey == valkeyp){
            ans += "#";
        }
        //cout << val << " " << valkey << " " << key[valkey] << endl;
        valkeyp = valkey;
        while (let[val] == valkey){
            ans += (char)(key[valkey] + '0');
            val--;
        }
    }
    cout << ans;
}

Compilation message

mobitel.cpp: In function 'int main()':
mobitel.cpp:25:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0; i < word.length(); i++){
                     ~~^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 3 ms 248 KB Output is correct
2 Correct 2 ms 364 KB Output is correct
3 Correct 2 ms 472 KB Output is correct
4 Correct 2 ms 520 KB Output is correct
5 Correct 2 ms 536 KB Output is correct
6 Correct 2 ms 628 KB Output is correct
7 Correct 2 ms 652 KB Output is correct
8 Correct 2 ms 652 KB Output is correct
9 Correct 2 ms 652 KB Output is correct
10 Correct 3 ms 760 KB Output is correct