Submission #1173038

#TimeUsernameProblemLanguageResultExecution timeMemory
1173038dzhoz0Mobitel (COCI14_mobitel)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define INF 1e18
#define f first
#define s second
#define pii pair<int, int>
#define vi vector<int>

const int MOD = 1'000'000'000 + 7;

void setIO(string name = "")
{
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
#ifdef LOCAL
    freopen("inp.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#else
    if (!name.empty())
    {
        freopen((name + ".INP").c_str(), "r", stdin);
        freopen((name + ".OUT").c_str(), "w", stdout);
    }
#endif
}
// START OF DEBUG
#define db(val) "["#val" = "<<(val)<<"] "
#define print_op(...) ostream& operator<<(ostream& out, const __VA_ARGS__& u)
// for printing std::pair
template<class U, class V> print_op(pair<U, V>) {
    return out << "(" << u.first << ", " << u.second << ")";
}
// for printing collection
template<class Con, class = decltype(begin(declval<Con>()))>
typename enable_if<!is_same<Con, string>::value, ostream&>::type
operator<<(ostream& out, const Con& con) { 
    out << "{";
    for (auto beg = con.begin(), it = beg; it != con.end(); ++it)
        out << (it == beg ? "" : ", ") << *it;
    return out << "}";
}
// for printing std::tuple
template<size_t i, class T> ostream& print_tuple_utils(ostream& out, const T& tup) {
    if constexpr(i == tuple_size<T>::value) return out << ")"; 
    else return print_tuple_utils<i + 1, T>(out << (i ? ", " : "(") << get<i>(tup), tup); 
}
template<class ...U> print_op(tuple<U...>) {
    return print_tuple_utils<0, tuple<U...>>(out, u);
}
// END OF DEBUG
string numbers[11] = {
    "",
    "",
    "abc",
    "def",
    "ghi",
    "jkl",
    "mno",
    "pqrs",
    "tuv",
    "wxyz"
};
map<char, pair<char, int>> mp;
int d[10]; // d[i]: press d[i] to get i
void solve()
{  
    for(int i = 1; i <= 9; i++) {
        int x; cin >> x;
        d[x] = i;
    }

    for(int i = 2; i <= 9; i++) {
        int x = d[i];
        char c = '0' + x;
        // cout << i << ' ' << x << ' ' << c << ' ' << numbers[i] << '\n';
        

        for(int j = 0; j < numbers[i].size(); j++) {
            mp[numbers[i][j]] = {char(x + '0'), j + 1};
        }
    } 
    // cout << char('0' + 4) << '\n';
    // cout << mp['l'] << '\n';
    vector<pair<char, int>> v;

    string s; cin >> s;
    for(char c : s) {
        if(!v.empty() && v.back().f == mp[c].f) v.push_back({'#', 1});
        v.push_back(mp[c]);
    }
    // cout << v << '\n';
    for(auto it : v) {
        while(it.s--) {
            cout << it.f;
        }
    }
    // cout << '\n';

    
}
signed main()
{
    setIO();
    int t = 1;
    // cin >> t;
    while (t--)
        solve();
}

Compilation message (stderr)

mobitel.cpp: In function 'void solve()':
mobitel.cpp:80:28: error: reference to 'numbers' is ambiguous
   80 |         for(int j = 0; j < numbers[i].size(); j++) {
      |                            ^~~~~~~
In file included from /usr/include/c++/11/bits/max_size_type.h:37,
                 from /usr/include/c++/11/bits/ranges_base.h:38,
                 from /usr/include/c++/11/string_view:48,
                 from /usr/include/c++/11/bits/basic_string.h:48,
                 from /usr/include/c++/11/string:55,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from mobitel.cpp:1:
/usr/include/c++/11/numbers:48:11: note: candidates are: 'namespace std::numbers { }'
   48 | namespace numbers
      |           ^~~~~~~
mobitel.cpp:53:8: note:                 'std::string numbers [11]'
   53 | string numbers[11] = {
      |        ^~~~~~~
mobitel.cpp:81:16: error: reference to 'numbers' is ambiguous
   81 |             mp[numbers[i][j]] = {char(x + '0'), j + 1};
      |                ^~~~~~~
In file included from /usr/include/c++/11/bits/max_size_type.h:37,
                 from /usr/include/c++/11/bits/ranges_base.h:38,
                 from /usr/include/c++/11/string_view:48,
                 from /usr/include/c++/11/bits/basic_string.h:48,
                 from /usr/include/c++/11/string:55,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from mobitel.cpp:1:
/usr/include/c++/11/numbers:48:11: note: candidates are: 'namespace std::numbers { }'
   48 | namespace numbers
      |           ^~~~~~~
mobitel.cpp:53:8: note:                 'std::string numbers [11]'
   53 | string numbers[11] = {
      |        ^~~~~~~
mobitel.cpp: In function 'void setIO(std::string)':
mobitel.cpp:23:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |         freopen((name + ".INP").c_str(), "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
mobitel.cpp:24:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |         freopen((name + ".OUT").c_str(), "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~