Submission #758115

#TimeUsernameProblemLanguageResultExecution timeMemory
758115KN200711Mobitel (COCI14_mobitel)C++14
50 / 50
1 ms316 KiB
# include <bits/stdc++.h> # define ll long long using namespace std; int pos[10]; int val(char a) { int x = a - 'a'; x /= 3; x += 2; if(a == 'p' || a == 'q' || a == 'r' || a == 's') return 7; if(a == 't' || a == 'u' || a == 'v') return 8; if(a == 'w' || a == 'x' || a == 'y' || a == 'z') return 9; return x; } int ch(char a) { int x = a - 'a'; // cout<<x<<endl; x %= 3; x++; if(a == 'p' || a == 't' || a == 'w') return 1; if(a == 'q' || a == 'u' || a == 'x') return 2; if(a == 'r' || a == 'v' || a == 'y') return 3; if(a == 's' || a == 'z') return 4; return x; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); for(int i=1;i<=9;i++) { int a; cin>>a; pos[a] = i; } string S; cin>>S; for(int i=0;i<S.length();i++) { if(i > 0 && val(S[i - 1]) == val(S[i])) { cout<<"#"; } for(int d=0;d<ch(S[i]);d++) cout<<pos[val(S[i])]; } }

Compilation message (stderr)

mobitel.cpp: In function 'int main()':
mobitel.cpp:42:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |  for(int i=0;i<S.length();i++) {
      |              ~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...