110852024-07-06 21:02:38GervidMorze (60 pont)cpp17Elfogadva 60/603ms504 KiB
#include <iostream>
#include <cstdio>

int main()
{
	std::cin.tie(nullptr);
	std::ios::sync_with_stdio(false);

	char buffer[1001];
	int i = 0;

	std::cin.getline(buffer, 1001);

	char output[201];
	int j = 0;

    while (buffer[i] != '\0')
    {
        char morse_digit = (((buffer[i] == '-') << 4) | ((buffer[i + 1] == '-') << 3) | ((buffer[i + 2] == '-') << 2) | ((buffer[i + 3] == '-') << 1) | (buffer[i + 4] == '-'));
        i += 5;
        switch (morse_digit)
        {
            case char(0b11111) : output[j++] = '0'; break;
            case char(0b01111) : output[j++] = '1'; break;
            case char(0b00111) : output[j++] = '2'; break;
            case char(0b00011) : output[j++] = '3'; break;
            case char(0b00001) : output[j++] = '4'; break;
            case char(0) :       output[j++] = '5'; break;
            case char(0b10000) : output[j++] = '6'; break;
            case char(0b11000) : output[j++] = '7'; break;
            case char(0b11100) : output[j++] = '8'; break;
            case char(0b11110) : output[j++] = '9'; break;
        }
    }

	output[j] = '\0';
	std::printf("%s\n", output);

	return 0;
}
RészfeladatÖsszpontTesztVerdiktIdőMemória
base60/60
1Elfogadva0/02ms356 KiB
2Elfogadva0/03ms356 KiB
3Elfogadva3/33ms376 KiB
4Elfogadva3/33ms348 KiB
5Elfogadva3/32ms360 KiB
6Elfogadva3/33ms284 KiB
7Elfogadva3/33ms504 KiB
8Elfogadva3/32ms376 KiB
9Elfogadva4/43ms504 KiB
10Elfogadva4/43ms356 KiB
11Elfogadva4/43ms356 KiB
12Elfogadva7/73ms504 KiB
13Elfogadva7/72ms376 KiB
14Elfogadva8/82ms504 KiB
15Elfogadva8/82ms352 KiB