Submission #483985

# Submission time Handle Problem Language Result Execution time Memory
483985 2021-11-01T18:41:39 Z ktkerem Mobitel (COCI14_mobitel) C++17
50 / 50
1 ms 312 KB
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
ll _i=0;
#define ffn(x) _i=x
#define fora(y,x) for(ll y=_i;x>y;y++)
#define pb push_back
#define pf push_front
#define debu cout << "hello\n"
#define fi first
#define sec second
const ll limit =998244353; 
const ll ous=1000005;
void solve(){
    vector<vector<char>> kb =  {{'a','b','c'} , {'d','e','f'} , {'g','h','i'} , {'j','k','l'} , {'m','n','o'} , {'p','q','r','s'} , {'t','u','v'} , {'w','x','y','z'}};
    string h;
    ll ar[10] , x;
    fora(i , 9){
        cin >> x;
        ar[x-1] = i+1;
    }
    cin >> h;
    ll n = h.length();
    ll pre = -1;
    fora(i , n){
        ll no ,ss , kd=0 , o=0;
        for(auto j:kb){
            ss = 0;
            for(auto k:j){
                ss++;
                if(k == h[i]){
                    no = o;
                    kd=1;
                    break;
                }
            }
            o++;
            if(kd==1){
                break;
            }
        } 
        if(pre == no){
            cout << "#";
        }
        fora(i,ss){
            cout << ar[no+1];
        }
        pre=no;
    }
    return;
}
int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    ll t=1;
    //cin >> t;
    while(t--){
        solve();
    }
    return 0; 
}

Compilation message

mobitel.cpp: In function 'void solve()':
mobitel.cpp:6:32: warning: 'ss' may be used uninitialized in this function [-Wmaybe-uninitialized]
    6 | #define fora(y,x) for(ll y=_i;x>y;y++)
      |                                ^
mobitel.cpp:26:16: note: 'ss' was declared here
   26 |         ll no ,ss , kd=0 , o=0;
      |                ^~
mobitel.cpp:46:26: warning: 'no' may be used uninitialized in this function [-Wmaybe-uninitialized]
   46 |             cout << ar[no+1];
      |                        ~~^~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 312 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 312 KB Output is correct
10 Correct 0 ms 204 KB Output is correct