답안 #201303

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
201303 2020-02-10T07:12:56 Z ArKCa 고장난 휴대전화기 (COCI14_mobitel) C++17
50 / 50
6 ms 504 KB
#include<bits/stdc++.h>
#define  f1   first
#define  s2   second
#define  pb   push_back
#define  pob  pop_back
#define  int  ll
#define  ll   long long 
#define  PII  pair<int,int> 
#define  N    11

using namespace std;


int n,a,last,b;
int dizi[N];

string s;
int calc(char c){
	if( c=='a' || c=='b' || c=='c' )return 2;
	if( c=='d' || c=='e' || c=='f' )return 3;
	if( c=='g' || c=='h' || c=='i' )return 4;
	if( c=='j' || c=='k' || c=='l' )return 5;
	if( c=='m' || c=='n' || c=='o' )return 6;
	if( c=='t' || c=='u' || c=='v' )return 8;
	if( c=='p' || c=='q' || c=='r' || c=='s' )return 7;
	if( c=='w' || c=='x' || c=='y' || c=='z' )return 9;
}
int calc1(char c){
	if( c=='a' || c=='d' || c=='g' || c=='j' || c=='m' || c=='t' || c=='p' || c=='w' )return 1;
	if( c=='b' || c=='e' || c=='h' || c=='k' || c=='n' || c=='u' || c=='q' || c=='x' )return 2;
	if( c=='c' || c=='f' || c=='i' || c=='l' || c=='o' || c=='v' || c=='r' || c=='y' )return 3;
	if( c=='s' || c=='z' )return 4;
}
int32_t main(){
	// freopen("a.gir","r",stdin);
	// freopen("a.cik","w",stdout);

	for(int i=1;i<=9;i++){
		scanf("%lld",&a);
		dizi[a]=i;
	}
	cin>>s;
	for(int i=0;i<s.size();i++){
		a=calc(s[i]);
		b=calc1(s[i]);
		if(a==last)
			printf("#");
		while(b--)
			printf("%lld",dizi[a] );
		last=a;
	}
}

Compilation message

mobitel.cpp: In function 'int32_t main()':
mobitel.cpp:43:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<s.size();i++){
              ~^~~~~~~~~
mobitel.cpp: In function 'long long int calc(char)':
mobitel.cpp:27:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
mobitel.cpp: In function 'long long int calc1(char)':
mobitel.cpp:33:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
mobitel.cpp: In function 'int32_t main()':
mobitel.cpp:39:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld",&a);
   ~~~~~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Correct 6 ms 256 KB Output is correct
4 Correct 5 ms 504 KB Output is correct
5 Correct 5 ms 256 KB Output is correct
6 Correct 6 ms 376 KB Output is correct
7 Correct 5 ms 256 KB Output is correct
8 Correct 5 ms 256 KB Output is correct
9 Correct 5 ms 256 KB Output is correct
10 Correct 5 ms 256 KB Output is correct