제출 #1100423

#제출 시각아이디문제언어결과실행 시간메모리
1100423bvv23고장난 휴대전화기 (COCI14_mobitel)C++17
50 / 50
2 ms504 KiB
// Ahmadov orz /// successful failure #include <bits/stdc++.h> /// #include <ext/pb_ds/assoc_container.hpp> using namespace std; /// using namespace __gnu_pbds; #define int long long #define pb push_back #define pii pair<int, int> #define all(v) v.begin(),v.end() #define ff first #define ss second #define drop(x) cout<<x<<endl;return // template <class T> // using isTree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; /// sometimes you gotta think simple struct custom_hash { size_t operator()(uint64_t x) const { static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count(); x ^= FIXED_RANDOM; return x ^ (x >> 16); } }; string ch[27] = { "2", "22", "222", "3", "33", "333", "4", "44", "444", "5", "55", "555", "6", "66", "666", "7", "77", "777", "7777", "8", "88", "888", "9", "99", "999", "9999" }; void failure() { unordered_map <int,int> mp; for (int i = 1; i <= 9; i++) { int x; cin >> x; mp[x] = i; } string s; cin >> s; string ans = ""; for (int i = 0; i < s.size() - 1; i++) { char c = s[i]; char cc = s[i + 1]; //cout << c << " " << cc << endl; ans += ch[s[i] - 'a']; if (ch[c - 'a'][0] == ch[cc - 'a'][0]) { ans += '#'; } } ans += ch[s[s.size() - 1] - 'a']; //cout << "!" << ans << endl; for (int i = 0; i < ans.size(); i++) { if (ans[i] != '#') { ans[i] = mp[ans[i] - '0'] + '0'; } } drop(ans); } signed main() { ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); int tt = 1; //cin >> tt; while (tt--) { failure(); } }

컴파일 시 표준 에러 (stderr) 메시지

mobitel.cpp: In function 'void failure()':
mobitel.cpp:46:23: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |     for (int i = 0; i < s.size() - 1; i++) {
      |                     ~~^~~~~~~~~~~~~~
mobitel.cpp:57:23: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   57 |     for (int i = 0; i < ans.size(); i++) {
      |                     ~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...