제출 #960253

#제출 시각아이디문제언어결과실행 시간메모리
960253khangrl고장난 휴대전화기 (COCI14_mobitel)C++14
0 / 50
1058 ms32516 KiB
#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++){ int a; cin>>a; arr[a]=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[2]==last){ cout<<'#'; } last=arr[2]; n='a'; n--; } else if(s[i]=='d' or s[i]=='e' or s[i]=='f'){ if(arr[3]==last){ cout<<'#'; } last=arr[3]; n='d'; n--; } else if(s[i]=='g' or s[i]=='h' or s[i]=='i'){ if(arr[4]==last){ cout<<'#'; } last=arr[4]; int n='g'; n--; } else if(s[i]=='j' or s[i]=='k' or s[i]=='l'){ if(arr[5]==last){ cout<<'#'; } last=arr[5]; n='j'; n--; } else if(s[i]=='m' or s[i]=='n' or s[i]=='o'){ if(arr[6]==last){ cout<<'#'; } last=arr[6]; n='m'; n--; } else if(s[i]=='p' or s[i]=='q' or s[i]=='r' or s[i]=='s'){ if(arr[7]==last){ cout<<'#'; } last=arr[7]; n='p'; n--; } else if(s[i]=='t' or s[i]=='u' or s[i]=='v'){ if(arr[8]==last){ cout<<'#'; } last=arr[8]; n='t'; n--; } else if(s[i]=='w' or s[i]=='x' or s[i]=='y' or s[i]=='z'){ if(arr[9]==last){ cout<<'w'; } last=arr[9]; n='w'; n--; } k-=n; while(k--){ cout<<last; } } }

컴파일 시 표준 에러 (stderr) 메시지

mobitel.cpp: In function 'int main()':
mobitel.cpp:17:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |  for(int i=0; i<s.size(); i++){
      |               ~^~~~~~~~~
mobitel.cpp:83:4: warning: 'n' may be used uninitialized in this function [-Wmaybe-uninitialized]
   83 |   k-=n;
      |   ~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...