Submission #23190

# Submission time Handle Problem Language Result Execution time Memory
23190 2017-05-04T11:39:51 Z model_code Karte (COCI15_karte) C++11
50 / 50
0 ms 2020 KB
#include <cstdio>
#include <iostream>
#include <cstring>

using namespace std;

const int MAXB = 5;
const int MAXN = 20;

bool bio[MAXB][MAXN];

int getColor(char chr) {
  if (chr == 'P') return 0;
  if (chr == 'K') return 1;
  if (chr == 'H') return 2;
  if (chr == 'T') return 3;
}

int main(void) {
  string s;
  cin >> s;
  for (int i = 0; i < s.size(); i += 3) {
    int b = getColor(s[i]);
    int x = (s[i + 1] - '0') * 10 + s[i + 2] - '0';
    if (bio[b][x]) {
      printf("GRESKA\n");
      return 0;
    }
    bio[b][x] = true;
  }

  for (int i = 0; i < 4; ++i) {
    int cnt = 0;
    for (int j = 1; j <= 13; ++j)
      if (bio[i][j])
	++cnt;
    printf("%d ",13 - cnt);
  }
  printf("\n");
    
  return 0;
}

Compilation message

karte.cpp: In function 'int main()':
karte.cpp:22:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int i = 0; i < s.size(); i += 3) {
                     ^
karte.cpp: In function 'int getColor(char)':
karte.cpp:17:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2020 KB Output is correct
2 Correct 0 ms 2020 KB Output is correct
3 Correct 0 ms 2020 KB Output is correct
4 Correct 0 ms 2020 KB Output is correct
5 Correct 0 ms 2020 KB Output is correct
6 Correct 0 ms 2020 KB Output is correct
7 Correct 0 ms 2020 KB Output is correct
8 Correct 0 ms 2020 KB Output is correct
9 Correct 0 ms 2020 KB Output is correct
10 Correct 0 ms 2020 KB Output is correct