Submission #328810

#TimeUsernameProblemLanguageResultExecution timeMemory
328810HalitMobitel (COCI14_mobitel)C++17
50 / 50
1 ms384 KiB
#include <bits/stdc++.h> using namespace std; int main(){ vector<int> v(9); for(int &e : v) cin >> e; vector<int> pre = { 0, 3, 6, 9, 12, 15, 19, 22, 26}; int last = 1; string s; cin >> s; auto to_int = [&](char ch){ return ch-'a'+1; }; auto write = [&](int cur){ int digit = 2, F; for(int i = 0;i+1 < 9;++i) if(cur > pre[i] && cur <= pre[i+1]) digit += i, F = cur-pre[i]; if(last == digit) cout << '#'; for(int j = 0;j < 9;++j) if(v[j] == digit) for(int i = 0;i < F;++i) cout << j+1; last = digit; }; for(char e : s) write(to_int(e)); }

Compilation message (stderr)

mobitel.cpp: In function 'int main()':
mobitel.cpp:29:21: warning: 'F' may be used uninitialized in this function [-Wmaybe-uninitialized]
   29 |     for(int i = 0;i < F;++i)
      |                   ~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...