답안 #959137

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
959137 2024-04-07T14:09:36 Z lalig777 Marko (COCI15_marko) C++14
50 / 50
37 ms 1116 KB
#include <iostream>
#include <vector>
#include <unordered_map>
using namespace std;

int main(){
    unordered_map<char, char>mapa;
    mapa['a']='2'; mapa['b']='2'; mapa['c']='2'; mapa['d']='3'; mapa['e']='3'; mapa['f']='3'; mapa['g']='4'; mapa['h']='4'; mapa['i']='4';
    mapa['j']='5'; mapa['k']='5'; mapa['l']='5'; mapa['m']='6'; mapa['n']='6'; mapa['o']='6'; mapa['p']='7'; mapa['q']='7'; mapa['r']='7';
    mapa['s']='7'; mapa['t']='8'; mapa['u']='8'; mapa['v']='8'; mapa['w']='9'; mapa['x']='9'; mapa['y']='9'; mapa['z']='9';
    int n;
    cin>>n;
    vector<string>v(n);
    vector<bool>val(n, true);
    for (int i=0; i<n; i++) cin>>v[i];
    string cod;
    cin>>cod;
    int ans=n;
    for (int i=0; i<cod.size(); i++){
        char c=cod[i];
        for (int j=0; j<n; j++){
            string s=v[j];
            if (val[j]==false) continue;
            if (s.size()<=i){
                ans--;
                val[j]=false;
            }
            else if (mapa[s[i]]!=c){
                ans--;
                val[j]=false;
            }
        }
    }int i=cod.size();
    for (int j=0; j<n; j++){
        string s=v[j];
        if (val[j]==false) continue;
        if (s.size()>i) ans--;
    }cout<<ans<<endl;
    return 0;
}

Compilation message

marko.cpp: In function 'int main()':
marko.cpp:19:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |     for (int i=0; i<cod.size(); i++){
      |                   ~^~~~~~~~~~~
marko.cpp:24:25: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   24 |             if (s.size()<=i){
      |                 ~~~~~~~~^~~
marko.cpp:37:21: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   37 |         if (s.size()>i) ans--;
      |             ~~~~~~~~^~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 600 KB Output is correct
4 Correct 37 ms 1116 KB Output is correct
5 Correct 3 ms 348 KB Output is correct
6 Correct 4 ms 348 KB Output is correct
7 Correct 8 ms 860 KB Output is correct
8 Correct 29 ms 1116 KB Output is correct
9 Correct 4 ms 348 KB Output is correct
10 Correct 23 ms 744 KB Output is correct