답안 #397552

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
397552 2021-05-02T11:19:33 Z Alma 고장난 휴대전화기 (COCI14_mobitel) C++17
50 / 50
1 ms 316 KB
#include <bits/stdc++.h>
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    unordered_map<int, int> puddle;
    int key;
    for (int i = 1; i <= 9; i++) {
        cin >> key;
        puddle[key] = i;
    }
    string s;
    cin >> s;
    int pre = 0;
    for (char c: s) {
        int act = c - 'a' + 1;
        if (1 <= act && act <= 3) { // a b c
            if (1 <= pre && pre <= 3) cout << '#';
            pre = act;
            for (int i = 1; i <= act; i++) cout << puddle[2];
        }
        if (4 <= act && act <= 6) { // d e f
            if (4 <= pre && pre <= 6) cout << '#';
            pre = act;
            for (int i = 4; i <= act; i++) cout << puddle[3];
        }
        if (7 <= act && act <= 9) { // g h i
            if (7 <= pre && pre <= 9) cout << '#';
            pre = act;
            for (int i = 7; i <= act; i++) cout << puddle[4];
        }
        if (10 <= act && act <= 12) { // j k l
            if (10 <= pre && pre <= 12) cout << '#';
            pre = act;
            for (int i = 10; i <= act; i++) cout << puddle[5];
        }
        if (13 <= act && act <= 15) { // m n o
            if (13 <= pre && pre <= 15) cout << '#';
            pre = act;
            for (int i = 13; i <= act; i++) cout << puddle[6];
        }
        if (16 <= act && act <= 19) { // p q r s
            if (16 <= pre && pre <= 19) cout << '#';
            pre = act;
            for (int i = 16; i <= act; i++) cout << puddle[7];
        }
        if (20 <= act && act <= 22) { // t u v
            if (20 <= pre && pre <= 22) cout << '#';
            pre = act;
            for (int i = 20; i <= act; i++) cout << puddle[8];
        }
        if (23 <= act && act <= 26) { // w x y z
            if (23 <= pre && pre <= 26) cout << '#';
            pre = act;
            for (int i = 23; i <= act; i++) cout << puddle[9];
        }
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 316 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct