답안 #299778

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
299778 2020-09-15T15:53:21 Z theshadow_04 고장난 휴대전화기 (COCI14_mobitel) C++14
50 / 50
1 ms 512 KB
// VU TRUONG AN
#include <bits/stdc++.h>
#define F first
#define S second
#define MOD 1000000007
#define pb push_back
#define bit(x,p) ((x>>p) & 1)
#define ll long long
#define Task "MOBITEL"
using namespace std;

const int base = 100003;
const int maxn = 100005;

string s[9] = {"000","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};
map<char,int> M,sl;
int main(){
    ios_base::sync_with_stdio(0);
    cout.tie(0); cin.tie(0);
	if(fopen(Task".inp","r")){
		freopen(Task".inp","r",stdin);
		freopen(Task".out","w",stdout);
	}
	for(int i = 1;i <= 9;++i){
        int a;
        cin >> a;
        if(a > 1){
            for(int j = 0;j < s[a - 1].length();++j){
                char c = s[a - 1][j];
                M[c] = i;
                sl[c] = j + 1;
            }
        }
	}
    string res;
    cin >> res;
    for(int i = 0;i < res.length();++i){
        if(M[res[i]] == M[res[i - 1]]) cout << '#';
        for(int j = 1;j <= sl[res[i]];++j) cout << M[res[i]];
    }
}

Compilation message

mobitel.cpp: In function 'int main()':
mobitel.cpp:28:29: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |             for(int j = 0;j < s[a - 1].length();++j){
      |                           ~~^~~~~~~~~~~~~~~~~~~
mobitel.cpp:37:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |     for(int i = 0;i < res.length();++i){
      |                   ~~^~~~~~~~~~~~~~
mobitel.cpp:21:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   21 |   freopen(Task".inp","r",stdin);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
mobitel.cpp:22:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   22 |   freopen(Task".out","w",stdout);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 512 KB Output is correct