QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#486814 | #4523. It's Raining, Man / Ancient Cards | inksamurai | WA | 238ms | 3796kb | C++23 | 3.4kb | 2024-07-22 03:13:41 | 2024-07-22 03:13:42 |
Judging History
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;
}
if(ch=='X'){
return 10;
}
if(ch=='J'){
return 11;
}
if(ch=='Q'){
return 12;
}
if(ch=='K'){
return 13;
}
assert(0);
return -1;
}
int getrank(char ch){
if(ch=='C'){
return 0;
}
if(ch=='D'){
return 1;
}
if(ch=='H'){
return 2;
}
if(ch=='S'){
return 3;
}
assert(0);
return -1;
}
int n;
const int SI=14;
void slv(){
vec(vi) a(4);
vec(vi) cnt(4,vi(SI));
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(array<int,3>) take){
// vec(pii) way;
auto dfs=[&](auto self,int i,int lst=-1)->void{
if(i==sz(take)){
pns=1;
// for(auto p:way){
// print(p.fi,p.se);
// }
// exit(0);
return;
}
auto [x,c,forced]=take[i];
if(lst==-1){
rep(j,SI){
if(cnt[x][j]>0){
// way.pb({x,j});
cnt[x][j]-=1;
self(self,i+1,j);
cnt[x][j]+=1;
// way.pop_back();
}
}
}else{
if(cnt[x][lst]==0){
return;
}
// way.pb({x,lst});
cnt[x][lst]-=1;
if(c==1){
self(self,i+1,lst);
}else{
bool fnd=0;
rep(j,SI){
if(cnt[x][j]>0){
fnd=1;
// way.pb({x,j});
cnt[x][j]-=1;
self(self,i+1,j);
cnt[x][j]+=1;
// way.pop_back();
}
}
if(forced){
if(!fnd){
self(self,i+1,lst);
}
}else{
self(self,i+1,lst);
}
}
cnt[x][lst]+=1;
// way.pop_back();
}
};
dfs(dfs,0,-1);
};
do{
if(pns) break;
vec(array<int,3>) take;
if(sz(ert)==3){
take.pb({ert[0],1,0});
take.pb({ert[1],2,1});
take.pb({ert[2],1,0});
ask(take);
}else if(sz(ert)==2){
take.pb({ert[0],1,0});
take.pb({ert[1],1,0});
ask(take);
}else{
int pvt=ert[0];
take={
{pvt,1,0},
{ert[1],2,1},
{ert[2],2,1},
{ert[3],1,0}
};
ask(take);
// take={
// {ert[1],1,0},
// {pvt,2,1},
// {ert[2],2,1},
// {ert[3],1,0}
// };
// ask(take);
take={
{ert[1],1,0},
{pvt,1,0},
{ert[2],2,1},
{pvt,1,0},
{ert[3],1,0}
};
ask(take);
take={
{ert[1],1,0},
{ert[2],2,1},
{pvt,2,1},
{ert[3],1,0}
};
ask(take);
take={
{ert[1],1,0},
{pvt,2,1},
{ert[2],2,1},
{ert[3],1,0}
};
ask(take);
take={
{ert[1],1,0},
{pvt,2,1},
{ert[2],2,1},
{pvt,2,1},
{ert[3],1,0}
};
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: 238ms
memory: 3796kb
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 YES YES NO 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 456th lines differ - expected: 'NO', found: 'YES'