QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#751019#9631. Median Replacementtz3528WA 0ms3608kbC++232.5kb2024-11-15 16:46:262024-11-15 16:46:26

Judging History

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

  • [2024-11-15 16:46:26]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3608kb
  • [2024-11-15 16:46:26]
  • 提交

answer

#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;



void solve() {
	int n, m;
	cin >> n >> m;
	int tota = n, totb = m;
	std::vector<int> cnta(15), cntb(15);
	char c;
	for(int i = 1; i <= n; i ++ ) {
		cin >> c;
		if(c >= '0' && c <= '9') {
			cnta[int(c - '0')] ++ ;
		} else if(c == 'T') {
			cnta[10] ++ ;
		} else if(c == 'J') {
			cnta[11] ++ ;
		} else if(c == 'Q') {
			cnta[12] ++ ;
		} else if(c == 'K') {
			cnta[13] ++ ;
		} else if(c == 'A') {
			cnta[14] ++ ;
		}
		cin >> c;
	}
	for(int i = 1; i <= m; i ++ ) {
		cin >> c;
		if(c >= '0' && c <= '9') {
			cntb[int(c - '0')] ++ ;
		} else if(c == 'T') {
			cntb[10] ++ ;
		} else if(c == 'J') {
			cntb[11] ++ ;
		} else if(c == 'Q') {
			cntb[12] ++ ;
		} else if(c == 'K') {
			cntb[13] ++ ;
		} else if(c == 'A') {
			cntb[14] ++ ;
		}
		cin >> c;
	}
	int x;
	cin >> c;
	if(c >= '0' && c <= '9') {
		x = int(c - '0');
	} else if(c == 'T') {
		x = 10;
	} else if(c == 'J') {
		x = 11;
	} else if(c == 'Q') {
		x = 12;
	} else if(c == 'K') {
		x = 13;
	} else if(c == 'A') {
		x = 14;
	}
	cin >> c;
	
	int minn = 1e9;
	for(int i = 1; i <= 14; i ++ ) {
		if(cnta[i]) {
			minn = i;
			break;
		}
	}
	if(minn >= x || tota == 1) {
		cout << "Shou\n";
		return ;
	}
	if(m==1){
		int b=0;
		for(int i=1;i<=14;i++){
			if(cntb[i]){
				b=i;
				break;
			}
		}
		if(b<x){
			for(int i=1;i<=14;i++){
				if(i>=b&&i<x&&cnta[i]){
					cout<<"Pang\n";
					return ;
				}
			}
		}
	}
	cnta[minn] -- ;
	tota -- ;
	int maxa = 0, maxb = 0;
	for(int i = 1; i <= 14; i ++ ) {
		if(cnta[i]) {
			maxa = i;
		}
		if(cntb[i]) {
			maxb = i;
		}
	}
	if(maxb<=minn){
		cout<<"Pang\n";
		return ;
	}
	for(int i = x; i <= 14; i ++ ) {
		if(cntb[i]) {
			cntb[i] -- ;
			totb -- ;
			break;
		}
	}
	int valb = 0;
	for(int i = 1; i <= 14; i ++ ) {
		if(cntb[i]) {
			if(i < x) {
				valb = i;
			}
		}
	}
	int now = 0;
	for(int i = 1; i < x; i ++ ) {
		now += cntb[i];
	}
	// cout << x << ' ' << now << '\n';
	if(now == 0) {
		cout << "Shou\n";
		return ;
	}
	if(now >= 2) {
		cout << "Pang\n";
		return ;
	}
	if(maxa > maxb && tota > 2) {
		for(int i = valb; i < x; i ++ ) {
			if(cnta[i]) {
				cout << "Pang\n";
				return ;
			}
		}
	} 
	cout << "Shou\n";
}

/*
  1
  3 2
  5H 9D 5H
  3H 8D
  6S
 */
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	
	int t = 1;
	cin >> t;
	while(t -- ) {
		solve();
	}
	
	return 0;
}

详细

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3608kb

input:

10
5
5 1 4 3 2
14 2 5 3 2
5
4 5 1 2 3
13 7 1 2 3
5
5 2 5 3 1
10 2 12 3 2
5
5 5 3 1 5
57 5 3 1 5
5
2 2 3 3 5
4 5 4 4 5
5
4 5 3 5 3
13 7 3 5 3
5
5 1 4 2 3
14 3 4 2 3
5
1 2 5 4 5
2 8 5 7 5
5
1 1 3 5 1
8 2 3 8 1
5
4 4 4 2 3
5 10 5 2 3

output:

Shou
Shou
Shou
Pang
Shou
Shou
Shou
Shou
Shou
Shou

result:

wrong answer 1st lines differ - expected: '180', found: 'Shou'