QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#185707#5065. Beautiful Stringykpcx#RE 0ms0kbC++171.8kb2023-09-22 15:28:532023-09-22 15:28:54

Judging History

你现在查看的是最新测评结果

  • [2023-09-22 15:28:54]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2023-09-22 15:28:53]
  • 提交

answer

#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <queue>
#include <bitset>

using namespace std;
using ll = long long;
const int N = 55;

int n, m, a[N], b[N], p;

int read() {
  string x;
  cin >> x;
  int ret;
  if ('2' <= x[0] && x[0] <= '9') ret = x[0] - '0';
  else if (x[0] == 'T') ret = 10;
  else if (x[0] == 'J') ret = 11;
  else if (x[0] == 'Q') ret = 12;
  else if (x[0] == 'K') ret = 13;
  else if (x[0] == 'A') ret = 14;

  return ret;
}

bool solve() {
  cin >> n >> m;
  for (int i = 0; i < n; i++) a[i] = read();
  for (int j = 0; j < m; j++) b[j] = read();
  p = read();
  if (n == 1) return false;

  int bmax = *max_element(b, b + m);
  int amax = *max_element(a, a + n);
  int alc = 0;
  int mal = -1;
  int blc = 0;
  int mbl = -1;
  for (int i = 0; i < n; i++) {
    if (a[i] < p) {
      alc++;
      mal = max(mal, a[i]);
    }
  }

  for (int i = 0; i < m; i++) {
    if (b[i] < p) {
      blc++;
      mbl = max(mbl, b[i]);
    }
  }

  if (n == 2) {
    if (alc == 0) return false;
    if (m == 1) {
      return b[0] <= mal;
    }
    if (bmax <= mal) return true;
    // if (bmax)
    // sort(b, b + m);
    // auto ptr = upper_bound(b, b + m, mal);
    // if (*ptr < p) blc--;
    // int bgec = m - blc;
    // bgec--;
    // printf("blc = %d\n", blc);
    return blc > 1;
  }

  // if (n == 3) {
    
  // }

  
  if (blc == 0) {
    return false;
  } else if (blc == 1) {
    if (n == 3) return false;
    if (m == 1) return mal >= mbl; //
    return amax > bmax && alc >= 2 && mal >= mbl;
  } else if (blc >= 2) {
    return alc != 0;
  }


  // printf("%lld\n", ans);
  return false;
}

int main() {
  ios::sync_with_stdio(false); cin.tie(0);

  int t; cin >> t; while (t--)
    printf("%s\n", solve() ? "Pang" : "Shou");

  return 0;  
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Runtime Error

input:

2
114514
0000000

output:


result: