Submission #292453

#TimeUsernameProblemLanguageResultExecution timeMemory
2924537_7_7Karte (COCI15_karte)C++17
50 / 50
1 ms512 KiB
#include <bits/stdc++.h>

using namespace std;

int f(char c){
    if(c == 'P') return 0;
    if(c == 'K') return 1;
    if(c == 'H') return 2;
    if(c == 'T') return 3;
    return -1;
}
int main()
{
    ios_base::sync_with_stdio(false);

    string s;
    cin >> s;
    int used[4][14];
    int cnt[14] = {};
    for(int i = 0; i < (int)s.size(); i += 3){
        int x = (s[i + 1] - '0');
        x = x * 10 + (s[i + 2] - '0');
        if(used[f(s[i])][x] == 1){
            cout << "GRESKA\n";
            return 0;
        }
        cnt[f(s[i])] ++;
        used[f(s[i])][x] = 1;
    }
    for(int i = 0; i < 4; i ++) cout << 13 - cnt[i] << " ";
}

Compilation message (stderr)

karte.cpp: In function 'int main()':
karte.cpp:23:27: warning: 'used[-1][x]' may be used uninitialized in this function [-Wmaybe-uninitialized]
   23 |         if(used[f(s[i])][x] == 1){
      |            ~~~~~~~~~~~~~~~^
#Verdict Execution timeMemoryGrader output
Fetching results...