Submission #658432

# Submission time Handle Problem Language Result Execution time Memory
658432 2022-11-13T07:56:04 Z Nhoksocqt1 Karte (COCI15_karte) C++17
50 / 50
1 ms 332 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;
}

string str;
int cnt[4], idx[260];
bool dx[15][4];

void process() {
    cin >> str;
    idx['P'] = 0, idx['K'] = 1, idx['H'] = 2, idx['T'] = 3;

    int strLen(str.size());
    for (int i = 0; i < strLen; i += 3) {
        int rankc = idx[str[i]];
        int val = (str[i + 1] - '0') * 10 + str[i + 2] - '0';
        if(dx[val][rankc]) {
            cout << "GRESKA";
            return;
        }

        dx[val][rankc] = 1;
        ++cnt[rankc];
    }

    for (int i = 0; i < 4; ++i)
        cout << 13 - cnt[i] << ' ';
}

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

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

    process();
    return 0;
}

Compilation message

karte.cpp:6: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
    6 | #pragma GCC optimization ("O3")
      | 
karte.cpp:7: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
    7 | #pragma GCC optimization ("unroll-loops")
      | 
karte.cpp: In function 'void process()':
karte.cpp:57:31: warning: array subscript has type 'char' [-Wchar-subscripts]
   57 |         int rankc = idx[str[i]];
      |                               ^
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct