Submission #1020228

# Submission time Handle Problem Language Result Execution time Memory
1020228 2024-07-11T17:45:22 Z nguyen31hoang08minh2003 Karte (COCI15_karte) C++17
50 / 50
1 ms 508 KB
#include <set>
#include <map>
#include <list>
#include <ctime>
#include <cmath>
#include <queue>
#include <deque>
#include <stack>
#include <math.h>
#include <bitset>
#include <vector>
#include <string>
#include <cstdio>
#include <cctype>
#include <numeric>
#include <fstream>
#include <sstream>
#include <cstdlib>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <stdio.h>
#include <typeinfo>
#include <stdint.h>
#include <string.h>
#include <iterator>
#include <iostream>
#include <algorithm>
#include <strings.h>
#include <functional>
#include <unordered_set>
#include <unordered_map>
#define fore(i, a, b) for (int i = (a), i##_last = (b); i < i##_last; ++i)
#define fort(i, a, b) for (int i = (a), i##_last = (b); i <= i##_last; ++i)
#define ford(i, a, b) for (int i = (a), i##_last = (b); i >= i##_last; --i)
#define fi first
#define se second
#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;
using ld = long double;

template<class A, class B> bool maxi(A &a, const B &b) {return (a < b) ? (a = b, true):false;};
template<class A, class B> bool mini(A &a, const B &b) {return (a > b) ? (a = b, true):false;};

typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;

const string SUITS = "PKHT";

signed main() {

    unordered_set<int> numbers[300];
    int cardCount = 0, length, f[300]{};
    string S;

    #ifdef LOCAL
    freopen("input.INP", "r", stdin);
    #endif // LOCAL

    cin.tie(0) -> sync_with_stdio(0);
    cout.tie(0);

    cin >> S;

    length = S.size();

    for (int i = 0; i < length; i += 3) {
        numbers[S[i]].insert((S[i + 1] - '0') * 10 + S[i + 2] - '0');
        ++f[S[i]];
        if (f[S[i]] != numbers[S[i]].size()) {
            puts("GRESKA");
            return 0;
        }
    }

    for (const char &suit : SUITS)
        cout << 13 - f[suit] << ' ';

    cout << '\n';

    return 0;
}

Compilation message

karte.cpp: In function 'int main()':
karte.cpp:76:21: warning: array subscript has type 'char' [-Wchar-subscripts]
   76 |         numbers[S[i]].insert((S[i + 1] - '0') * 10 + S[i + 2] - '0');
      |                     ^
karte.cpp:77:17: warning: array subscript has type 'char' [-Wchar-subscripts]
   77 |         ++f[S[i]];
      |                 ^
karte.cpp:78:19: warning: array subscript has type 'char' [-Wchar-subscripts]
   78 |         if (f[S[i]] != numbers[S[i]].size()) {
      |                   ^
karte.cpp:78:36: warning: array subscript has type 'char' [-Wchar-subscripts]
   78 |         if (f[S[i]] != numbers[S[i]].size()) {
      |                                    ^
karte.cpp:78:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::unordered_set<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   78 |         if (f[S[i]] != numbers[S[i]].size()) {
      |             ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
karte.cpp:85:24: warning: array subscript has type 'char' [-Wchar-subscripts]
   85 |         cout << 13 - f[suit] << ' ';
      |                        ^~~~
karte.cpp:61:9: warning: unused variable 'cardCount' [-Wunused-variable]
   61 |     int cardCount = 0, length, f[300]{};
      |         ^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 508 KB Output is correct
4 Correct 0 ms 372 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 464 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct