Submission #695336

# Submission time Handle Problem Language Result Execution time Memory
695336 2023-02-05T03:09:08 Z Nhoksocqt1 Marko (COCI15_marko) C++17
50 / 50
6 ms 1108 KB
#include<bits/stdc++.h>
using namespace std;

#define inf 0x3f3f3f3f
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> ii;

template<class X, class Y>
	inline bool maximize(X &x, const Y &y) {return (x < y ? x = y, 1 : 0);}
template<class X, class Y>
	inline bool minimize(X &x, const Y &y) {return (x > y ? x = y, 1 : 0);}

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int Random(int l, int r) {
    return uniform_int_distribution<int>(l, r)(rng);
}

int readInt() {
	bool minus = false;
	int result = 0;
	char ch;
	ch = getchar();
	while(true) {
		if(ch == '-') break;
		if(ch >= '0' && ch <= '9') break;
		ch = getchar();
	}

	if(ch == '-') minus = true; else result = ch - '0';
	while(true) {
		ch = getchar();
		if (ch < '0' || ch > '9') break;
		result = result * 10 + (ch - '0');
	}

	if(minus)
		return -result;
	else
		return result;
}

map<string, int> Map;
int numWord;

inline int toKeyboardNumber(char c) {
    if(c <= 'o')
        return 2 + (c - 'a') / 3;

    return (c <= 's') ? 7 : 8 + (c > 'v');
}

void process() {
    cin >> numWord;
    for (int i = 1; i <= numWord; ++i) {
        string str, trans;
        cin >> str;
        for (int i = 0; i < str.size(); ++i)
            trans += char('0' + toKeyboardNumber(str[i]));

        ++Map[trans];
    }

    string str;
    cin >> str;
    cout << Map[str];
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

//    freopen("marko.inp", "r", stdin);
//    freopen("marko.out", "w", stdout);

    process();
    return 0;
}

Compilation message

marko.cpp:6: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
    6 | #pragma GCC optimization ("O3")
      | 
marko.cpp:7: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
    7 | #pragma GCC optimization ("unroll-loops")
      | 
marko.cpp: In function 'void process()':
marko.cpp:62:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   62 |         for (int i = 0; i < str.size(); ++i)
      |                         ~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 280 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 6 ms 980 KB Output is correct
5 Correct 1 ms 404 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 4 ms 872 KB Output is correct
8 Correct 6 ms 1108 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 4 ms 852 KB Output is correct