Submission #87700

#TimeUsernameProblemLanguageResultExecution timeMemory
87700asifthegreatMobitel (COCI14_mobitel)C++14
50 / 50
3 ms604 KiB
#include <bits/stdc++.h> using namespace std; int mp[100]; map<char,int>number; void doit() { number['a'] = 2; number['b'] = 2; number['c'] = 2; number['d'] = 3; number['e'] = 3; number['f'] = 3; number['g'] = 4; number['h'] = 4; number['i'] = 4; number['j'] = 5; number['k'] = 5; number['l'] = 5; number['m'] = 6; number['n'] = 6; number['o'] = 6; number['p'] = 7; number['q'] = 7; number['r'] = 7; number['s'] = 7; number['t'] = 8; number['u'] = 8; number['v'] = 8; number['w'] = 9; number['x'] = 9; number['y'] = 9; number['z'] = 9; } int main() { doit(); int ss; for(int i = 1; i <= 9;i++){ scanf("%d",&ss); mp[ss] = i; } string s,ans; cin >> s; int size = s.size(); for(int i = 0; i < size;i++){ int k = number[s[i]]; int cnt = 0; for(char x = s[i];x >= 'a';x--){ if(number[x] == k)cnt++; } //cout << k << " " << cnt << endl; if(ans.empty() or ans.back() != k+'0'){ //cout << "papa " << endl; for(int p = 1; p <= cnt;p++)ans.push_back((char)(k+'0')); } else{ ans.push_back('#'); for(int p = 1; p <= cnt;p++)ans.push_back((char)(k+'0')); } } //cout << ans << endl; for(auto i: ans){ if(i == '#')cout << i; else{ int k = i-'0'; cout << mp[k]; } } return 0; }

Compilation message (stderr)

mobitel.cpp: In function 'int main()':
mobitel.cpp:43:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&ss);
   ~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...