답안 #960250

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
960250 2024-04-10T03:40:19 Z khangrl 고장난 휴대전화기 (COCI14_mobitel) C++14
0 / 50
1 ms 348 KB
#include<bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
#define pb push_back
using namespace std;
int main(){
	int arr[10];
	for(int i=1; i<=9; i++){
		cin>>arr[i];
	}
	string s;
	cin>>s;
	int last=0;
	for(int i=0; i<s.size(); i++){
		int n, k=s[i];
		if(s[i]=='a' or s[i]=='b' or s[i]=='c'){
			if(arr[1]==last){
				cout<<'#';
			}
			last=arr[1];
			n='a';
			n--;
		}
		else if(s[i]=='d' or s[i]=='e' or s[i]=='f'){
			if(arr[2]==last){
				cout<<'#';
			}			
		    last=arr[2];
			n='d';
			n--;
	    }
		else if(s[i]=='g' or s[i]=='h' or s[i]=='i'){
			if(arr[3]==last){
				cout<<'#';
			}
			last=arr[3];
			int n='g';
			n--;
	    }
		else if(s[i]=='j' or s[i]=='k' or s[i]=='l'){
			if(arr[4]==last){
				cout<<'#';
			}
			last=arr[4];
			n='j';
			n--;
		}
		else if(s[i]=='m' or s[i]=='n' or s[i]=='o'){
			if(arr[5]==last){
				cout<<'#';
			}
			last=arr[5];
			n='m';
			n--;
		}
		else if(s[i]=='p' or s[i]=='q' or s[i]=='r' or s[i]=='s'){
			if(arr[6]==last){
				cout<<'#';
			}
			last=arr[6];
			n='p';
			n--;
		}
		else if(s[i]=='t' or s[i]=='u' or s[i]=='v'){
			if(arr[7]==last){
				cout<<'#';
			}
			last=arr[7];
			n='t';
			n--;
		}
		else if(s[i]=='w' or s[i]=='x' or s[i]=='y' or s[i]=='z'){
			if(arr[8]==last){
				cout<<'w';
			}
			last=arr[8];
			n='a';
			n--;
		}
		k-=n;
		while(k--){
			cout<<last;
		}
	}
}

Compilation message

mobitel.cpp: In function 'int main()':
mobitel.cpp:15:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |  for(int i=0; i<s.size(); i++){
      |               ~^~~~~~~~~
mobitel.cpp:81:4: warning: 'n' may be used uninitialized in this function [-Wmaybe-uninitialized]
   81 |   k-=n;
      |   ~^~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -