Submission #292453

# Submission time Handle Problem Language Result Execution time Memory
292453 2020-09-07T02:26:30 Z 7_7_7 Karte (COCI15_karte) C++17
50 / 50
1 ms 512 KB
#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

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 time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 1 ms 512 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct