QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#486801#4523. It's Raining, Man / Ancient CardsinksamuraiWA 17ms3672kbC++233.4kb2024-07-22 02:35:392024-07-22 02:35:39

Judging History

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

  • [2024-07-22 02:35:39]
  • 评测
  • 测评结果:WA
  • 用时:17ms
  • 内存:3672kb
  • [2024-07-22 02:35:39]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define rng(i,c,n) for(int i=c;i<n;i++)
#define fi first
#define se second
#define pb push_back
#define sz(a) (int) a.size()
#define all(a) a.begin(),a.end()
#define vec(...) vector<__VA_ARGS__>
#define _3Wcdivh ios::sync_with_stdio(0),cin.tie(0)
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
void print(){cout<<'\n';}
template<class h,class...t>
void print(const h&v,const t&...u){cout<<v<<' ',print(u...);}

int getnum(char ch){
	if(ch>='2' and ch<='9'){
		return ch-'0';
	}
	if(ch=='A'){
		return 0;
	}
	return 10;
}

int getrank(char ch){
	if(ch=='C'){
		return 0;
	}
	if(ch=='D'){
		return 1;
	}
	if(ch=='H'){
		return 2;
	}
	return 3;
}

int n;

void slv(){
	vec(vi) a(4);
	vec(vi) cnt(4,vi(11));
	rep(i,n){
		string s;
		cin>>s;
		int x=getnum(s[0]);
		int y=getrank(s[1]);
		a[y].pb(x);
		cnt[y][x]+=1;
	}
	vi ert;
	rep(i,4){
		if(sz(a[i])){
			ert.pb(i);
		}
	}
	if(sz(ert)==1){
		cout<<"YES\n";
		return;
	}
	bool pns=0;
	
	auto ask=[&](vec(pii) take){
		auto dfs=[&](auto self,int i,int lst=-1)->void{
			if(i==sz(take)){
				pns=1;
				return;
			}
			auto [x,c]=take[i];
			if(lst==-1){
				rep(j,11){
					if(cnt[x][j]>0){
						cnt[x][j]-=1;
						self(self,i+1,j);
						cnt[x][j]+=1;
					}
				}
			}else{
				if(cnt[x][lst]==0){
					return;
				}
				cnt[x][lst]-=1;
				if(c==1){
					self(self,i+1,lst);
				}else{
					bool fnd=0;
					rep(j,11){
						if(cnt[x][j]>0){
							fnd=1;
							cnt[x][j]-=1;
							self(self,i+1,j);
							cnt[x][j]+=1;
						}
					}
					// if(!fnd){
					// 	self(self,i+1,lst);
					// }
				}
				cnt[x][lst]+=1;
			}
		};
		dfs(dfs,0,-1);
	};

	do{
		if(pns) break;
		vec(pii) take;
		if(sz(ert)==3){
			take.pb({ert[0],1});
			take.pb({ert[1],2});
			take.pb({ert[2],1});
			ask(take);
		}else if(sz(ert)==2){
			take.pb({ert[0],1});
			take.pb({ert[1],1});
			ask(take);
		}else{
			int pvt=ert[0];
			take={
				{pvt,1},
				{ert[1],2},
				{ert[2],2},
				{ert[3],1}
			};
			ask(take);
			// take={
			// 	{pvt,1},
			// 	{ert[1],2},
			// 	{pvt,1},
			// 	{ert[2],2},
			// 	{ert[3],1}
			// };
			// ask(take);
			// take={
			// 	{pvt,1},
			// 	{ert[1],2},
			// 	{ert[2],2},
			// 	{pvt,1},
			// 	{ert[3],1}
			// };
			// ask(take);
			// take={
			// 	{pvt,1},
			// 	{ert[1],2},
			// 	{pvt,1},
			// 	{ert[2],2},
			// 	{pvt,1},
			// 	{ert[3],1}
			// };
			// ask(take);
			// take={
			// 	{ert[1],1},
			// 	{pvt,2},
			// 	{ert[2],2},
			// 	{ert[3],1}
			// };
			// ask(take);
			// take={
			// 	{ert[1],1},
			// 	{pvt,2},
			// 	{ert[2],2},
			// 	{pvt,2},
			// 	{ert[3],1}
			// };
			// ask(take);
			// take={
			// 	{ert[1],1},
			// 	{pvt,2},
			// 	{ert[2],2},
			// 	{pvt,1},
			// 	{ert[3],1}
			// };
			// ask(take);
			// take={
			// 	{ert[1],1},
			// 	{ert[2],2},
			// 	{pvt,2},
			// 	{ert[3],1}
			// };
			// ask(take);
			// take={
			// 	{ert[1],1},
			// 	{pvt,1},
			// 	{ert[2],2},
			// 	{pvt,2},
			// 	{ert[3],1}
			// };
			// ask(take);
		}
	}while(next_permutation(all(ert)));
	cout<<(pns?"YES":"NO")<<"\n";
}

signed main(){
_3Wcdivh;
	while(cin>>n){
		slv();
	}
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 17ms
memory: 3672kb

input:

37 2S 3S 4S 6S 7S 8S 9S XS JS QS KS AS 5D 2H 3H 4H 6H 7H 8H 9H XH JH QH KH AH 2C 3C 4C 6C 7C 8C 9C XC JC QC KC AC
36 3S 4S 6S 7S 8S 9S XS JS QS KS AS 5D 2H 3H 4H 6H 7H 8H 9H XH JH QH KH AH 2C 3C 4C 6C 7C 8C 9C XC JC QC KC AC
36 2S 4S 6S 7S 8S 9S XS JS QS KS AS 5D 2H 3H 4H 6H 7H 8H 9H XH JH QH KH AH ...

output:

NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
NO
YES
YES
YES
YES
YES
YES
YES
YES
NO
NO
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
...

result:

wrong answer 54th lines differ - expected: 'YES', found: 'NO'