#2327554

Solution for ITP1_6_B: Finding Missing Cards by motorman

Source Code Status Test Cases
    Policy: public     Reviewed: 2    
00.00 sec    3052 KB    63 lines     998 bytes    2017-05-20 02:45
#include <iostream>

using namespace std;

inline int suit_to_id(char c) {
  switch (c) {
    case 'S':
      return 0;
    case 'H':
      return 13;
    case 'C':
      return 26;
    case 'D':
      return 39;
  }
  // should not reach here
  return 0;
}

inline char id_to_suit(int i) {
  switch (i) {
    case 0 ... 12:
      return 'S';
    case 13 ... 25:
      return 'H';
    case 26 ... 38:
      return 'C';
    case 39 ... 51:
      return 'D';
  }
  // should not reach here
  return 'S';
}

int main() {
  // 0..12 => S1..S13
  // 13..25 => H1..H13
  // 26..38 => C1..C13
  // 39..51 => D1..D13
  bool bits[52] = {false};

  int n;
  cin >> n;

  char c;
  int x;
  for (int i = 0; i < n; ++i) {
    cin >> c >> x;
    const int offset = suit_to_id(c);
    bits[offset + x - 1] = true;
  }

  for (int i = 0; i < 52; ++i) {
    if (!bits[i]) {
      const char s = id_to_suit(i);
      const int v = i - suit_to_id(s) + 1;
      cout << s << " " << v << endl;
    }
  }

  return 0;
}

Compile Error Logs:
You are not authorized to see the message.

Status
Judge: 4/4 C++ CPU: 00.00 sec Memory: 3052 KB Length: 998 B 2017-05-20 02:45 2017-05-20 02:45
Results for testcases
Case # Verdict CPU Time Memory In Out Case Name
Case #1: : Accepted 00.00 sec 2980 KB
Case #2: : Accepted 00.00 sec 2980 KB
Case #3: : Accepted 00.00 sec 3052 KB
Case #4: : Accepted 00.00 sec 2980 KB
< prev | / | next >  
 
Judge Input #  ( | ) Judge Output #  ( | )


Comments
 
 Under Construction.
 
Categories
 
 
Free Tags