Submission #51549

#TimeUsernameProblemLanguageResultExecution timeMemory
51549tranxuanbachMobitel (COCI14_mobitel)C++17
50 / 50
3 ms760 KiB
#include<bits/stdc++.h> #define int long long using namespace std; const int N = 10; int key[10]; int let[26] = {2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 9, 9, 9, 9}; signed main(){ for (int i = 1; i <= 9; i++){ int x; cin >> x; key[x] = i; } string word, ans = ""; cin >> word; int val, valkey, valkeyp = 0; for (int i = 0; i < word.length(); i++){ val = word[i] - 'a'; valkey = let[val]; if (valkey == valkeyp){ ans += "#"; } //cout << val << " " << valkey << " " << key[valkey] << endl; valkeyp = valkey; while (let[val] == valkey){ ans += (char)(key[valkey] + '0'); val--; } } cout << ans; }

Compilation message (stderr)

mobitel.cpp: In function 'int main()':
mobitel.cpp:25:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0; i < word.length(); i++){
                     ~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...