求条
查看原帖
求条
915481
ComeTheWay楼主2025/1/11 16:01

样例不过,TLE*5,WA*4

#include <bits/stdc++.h>
//#include <windows.h>
using namespace std;
int blood = 4, ans;
pair<int, bool> now;
int book[20];
map<char, int> mp = {{'0', 10}, {'A', 1}, {'2', 2}, {'3', 3}, {'4', 4}, {'5', 5}, {'6', 6}, {'7', 7}, {'8', 8}, {'9', 9}, {'J', 11}, {'Q', 12}, {'K', 13}};
bool step = 1;

struct node{
	deque<pair<int, bool>> a;
}arr[14]; 

signed main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	for (int i = 1; i <= 13; i++) {
		for (int j = 1; j <= 4; j++) {
			char t;
			cin >> t;
//			cout << mp[t] << " " << flush;
			if (i == 13 && j == 1) now = {mp[t], 1};
			else arr[i].a.push_back({mp[t], 1});
		}
//		cout << endl;
	}
//	cout << endl;
//	for (int i = 1; i <= 14; i++) {
//		while (!arr[i].a.empty()) {
//			cout << arr[i].a.back() << " ";
//			arr[i].a.pop_back();
//		}
//		cout << endl;
//	}
	while (1){
//		cout << now.first << " " << now.second << endl;
//		Sleep(100);
		if (now.first == 13) {
			blood --;
			if (blood == 0) break;
			step = 0;
		} else {
			arr[now.first].a.push_front({now.first, 0});
			if (now.second)book[now.first]++;
			step = 1;
		}
		if (!step) {
			now = arr[13].a.front();
			arr[13].a.pop_front();
		} else {
			now = arr[now.first].a.back();
			arr[now.first].a.pop_back();
		}
	}
	for (int i = 1; i <= 12; i++) {
		if (book[i] == 4) ans++;
	}
	cout << ans;
	return 0;
}
2025/1/11 16:01
加载中...