답안 #398733

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
398733 2021-05-04T18:55:20 Z Alexandra 고장난 휴대전화기 (COCI14_mobitel) C++14
0 / 50
1 ms 332 KB
#include <iostream>
#include <string>
#include <vector>

using namespace std;

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

	vector<int> n;
	string s, resp;
	int prev = 1;

	for (int i=1; i<=9; i++) {
		int in;
		cin >> in;
		n[in-1] = i;
	}
	cin >> s;

	for (int i=0; i<s.length(); i++) {
		if (s[i]=='a') {
			if (prev==2) {
				s+='#';
			}
			s+=n[0];
			prev=2;
		}

		else if (s[i]=='b') {
			if (prev==2) {
				s+='#';
			}
			s+=n[0] + n[0];
			prev=2;
		}

		else if (s[i]=='c') {
			if (prev==2) {
				s+='#';
			}
			s+=n[0] + n[0] + n[0];
			prev=2;
		}

		else if (s[i]=='d') {
			if (prev==3) {
				s+='#';
			}
			s+=n[1];
			prev=3;
		}

		else if (s[i]=='e') {
			if (prev==3) {
				s+='#';
			}
			s+=n[1] + n[1];
			prev=3;
		}

		else if (s[i]=='f') {
			if (prev==3) {
				s+='#';
			}
			s+=n[1] + n[1] + n[1];
			prev=3;
		}

		else if (s[i]=='g') {
			if (prev==4) {
				s+='#';
			}
			s+=n[2];
			prev=4;
		}

		else if (s[i]=='h') {
			if (prev==4) {
				s+='#';
			}
			s+=n[2] + n[2];
			prev=4;
		}

		else if (s[i]=='i') {
			if (prev==4) {
				s+='#';
			}
			s+=n[2] + n[2] + n[2];
			prev=4;
		}

		else if (s[i]=='j') {
			if (prev==5) {
				s+='#';
			}
			s+=n[3];
			prev=5;
		}

		else if (s[i]=='k') {
			if (prev==5) {
				s+='#';
			}
			s+=n[3] + n[3];
			prev=5;
		}

		else if (s[i]=='l') {
			if (prev==5) {
				s+='#';
			}
			s+=n[3] + n[3] + n[3];
			prev=5;
		}

		else if (s[i]=='m') {
			if (prev==6) {
				s+='#';
			}
			s+=n[4];
			prev=6;
		}

		else if (s[i]=='n') {
			if (prev==6) {
				s+='#';
			}
			s+=n[4] + n[4];
			prev=6;
		}

		else if (s[i]=='o') {
			if (prev==6) {
				s+='#';
			}
			s+=n[4] + n[4] + n[4];
			prev=6;
		}

		else if (s[i]=='p') {
			if (prev==7) {
				s+='#';
			}
			s+=n[5];
			prev=7;
		}

		else if (s[i]=='q') {
			if (prev==7) {
				s+='#';
			}
			s+=n[5] + n[5];
			prev=7;
		}

		else if (s[i]=='r') {
			if (prev==7) {
				s+='#';
			}
			s+=n[5] + n[5] + n[5];
			prev=7;
		}

		else if (s[i]=='s') {
			if (prev==7) {
				s+='#';
			}
			s+=n[5] + n[5] + n[5] + n[5];
			prev=7;
		}

		else if (s[i]=='t') {
			if (prev==8) {
				s+='#';
			}
			s+=n[6];
			prev=8;
		}

		else if (s[i]=='u') {
			if (prev==8) {
				s+='#';
			}
			s+=n[6] + n[6];
			prev=8;
		}

		else if (s[i]=='v') {
			if (prev==8) {
				s+='#';
			}
			s+=n[6] + n[6] + n[6];
			prev=8;
		}

		else if (s[i]=='w') {
			if (prev==9) {
				s+='#';
			}
			s+=n[7];
			prev=9;
		}

		else if (s[i]=='x') {
			if (prev==9) {
				s+='#';
			}
			s+=n[7] + n[7];
			prev=9;
		}

		else if (s[i]=='y') {
			if (prev==9) {
				s+='#';
			}
			s+=n[7] + n[7] + n[7];
			prev=9;
		}

		else if (s[i]=='z') {
			if (prev==9) {
				s+='#';
			}
			s+=n[7] + n[7] + n[7] + n[7];
			prev=9;
		}
	}
	cout << s;
}

Compilation message

mobitel.cpp: In function 'int main()':
mobitel.cpp:22:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |  for (int i=0; i<s.length(); i++) {
      |                ~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 332 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -