记录详情

Wrong Answer

/in/foo.cc: In function 'int read()':
/in/foo.cc:5:30: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
  while(ch>'9'||ch<'0')ch=='-'&&(f=0)||(ch=getchar());
                       ~~~~~~~^~~~~~~
# 状态 耗时 内存占用
#1 Wrong Answer 5ms 208.0 KiB
#2 Wrong Answer 5ms 216.0 KiB
#3 Wrong Answer 5ms 216.0 KiB
#4 Wrong Answer 1ms 204.0 KiB

代码

#include <bits/stdc++.h>
using namespace std;
inline int read(){
	int x=0,f=1;char ch=getchar();
	while(ch>'9'||ch<'0')ch=='-'&&(f=0)||(ch=getchar());
	while(ch<='9'&&ch>='0')x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
	return f?x:-x;
}

struct shoupai {
  int type;
  int size;
  friend bool operator < (const shoupai &a, const shoupai &b) {
    return a.type == b.type ? a.size < b.size : a.type > b.type;
  }
};

struct user {
  char name[20];
  shoupai pai;
  friend bool operator < (const user &a, const user &b) {
    if (a.pai < b.pai) return true;
    if (b.pai < a.pai) return false;
    return strcmp(a.name, b.name) < 0;
  }
} u[102];

char p1[20], p2[20], p3[20];

shoupai fenxipai(char* a) {
  int size = 0;
  if (strlen(a) > 2) {
    size = 10;
  } else if (a[1] >= '2' && a[1] <= '9') {
    size = a[1] - '0';
  } else if (a[1] == 'A') {
    size = 1;
  } else if (a[1] == 'K') {
    size = 13;
  } else if (a[1] == 'Q') {
    size = 12;
  } else if (a[1] == 'J') {
    size = 11;
  }
  int type = a[0] - 'a';
  return (shoupai) {
    type,
    size,
  };
}

shoupai fenxishoupai() {
  shoupai s1 = fenxipai(p1);
  shoupai s2 = fenxipai(p2);
  shoupai s3 = fenxipai(p3);

  if (s1.size > s2.size) swap(s1, s2);
  if (s2.size > s3.size) swap(s2, s3);
  if (s1.size > s2.size) swap(s1, s2);

  // s1 smallest, s3 largest
  // 豹子
  if (s1.size == s2.size && s2.size == s3.size) {
    return (shoupai) { 1, s1.size };
  }
  // 顺金
  if (s1.type == s2.type && s2.type == s3.type) {
    if (s2.size - s1.size == 1 && s3.size - s2.size == 1) {
      return (shoupai) { 2, s1.size };
    }
    if (s1.size == 1 && s2.size == 12 && s3.size == 13) {
      return (shoupai) { 2, 12 };
    }
    // 金花
    return (shoupai) { 3, s3.size * 10000 + s2.size * 100 + s1.size };
  }
  // 顺子
  if (s2.size - s1.size == 1 && s3.size - s2.size == 1) {
    return (shoupai) { 4, s1.size };
  }
  if (s1.size == 1 && s2.size == 12 && s3.size == 13) {
    return (shoupai) { 4, 12 };
  }
  // 对子
  if (s1.size == s2.size) {
    return (shoupai) { 5, s1.size * 100 + s3.size };
  }
  if (s2.size == s3.size) {
    return (shoupai) { 5, s2.size * 100 + s1.size };
  }
  // 单张
  return (shoupai) { 6, s3.size * 10000 + s2.size * 100 + s1.size };
}

int main() {
  int T = read();
  while (T --) {
    int n = read();
    for (int i = 1; i <= n; ++ i) {
      scanf("%s", u[i].name);
      scanf("%s%s%s", p1, p2, p3);
      u[i].pai = fenxishoupai();
    }
    sort(u + 1, u + n + 1);
    for (int i = n; i; -- i) {
      puts(u[i].name);
    }
  }
}

信息

递交者
类型
递交
题目
P1004 hitwh 2019 新生赛 E EdChu 与炸金花
语言
C++
递交时间
2020-12-17 10:18:55
评测时间
2020-12-17 10:18:55
评测机
分数
0
总耗时
17ms
峰值内存
216.0 KiB