- 斗地主
- 2016-11-17 22:37:04 @
**
测试数据 #0: Accepted, time = 0 ms, mem = 560 KiB, score = 1
测试数据 #1: Accepted, time = 0 ms, mem = 560 KiB, score = 1
测试数据 #2: Accepted, time = 0 ms, mem = 560 KiB, score = 1
测试数据 #3: Accepted, time = 0 ms, mem = 560 KiB, score = 1
测试数据 #4: Accepted, time = 0 ms, mem = 560 KiB, score = 1
测试数据 #5: Accepted, time = 15 ms, mem = 560 KiB, score = 1
测试数据 #6: Accepted, time = 0 ms, mem = 560 KiB, score = 1
测试数据 #7: Accepted, time = 0 ms, mem = 556 KiB, score = 1
测试数据 #8: Accepted, time = 0 ms, mem = 556 KiB, score = 1
测试数据 #9: Accepted, time = 0 ms, mem = 556 KiB, score = 1
测试数据 #10: Accepted, time = 0 ms, mem = 564 KiB, score = 1
测试数据 #11: Accepted, time = 0 ms, mem = 560 KiB, score = 1
测试数据 #12: Accepted, time = 0 ms, mem = 560 KiB, score = 1
测试数据 #13: Accepted, time = 15 ms, mem = 556 KiB, score = 1
测试数据 #14: Accepted, time = 0 ms, mem = 560 KiB, score = 1
测试数据 #15: Accepted, time = 0 ms, mem = 560 KiB, score = 1
测试数据 #16: Accepted, time = 0 ms, mem = 560 KiB, score = 1
测试数据 #17: Accepted, time = 0 ms, mem = 556 KiB, score = 1
测试数据 #18: Accepted, time = 0 ms, mem = 560 KiB, score = 1
测试数据 #19: Accepted, time = 0 ms, mem = 560 KiB, score = 1
测试数据 #20: Accepted, time = 0 ms, mem = 560 KiB, score = 1
测试数据 #21: Accepted, time = 0 ms, mem = 564 KiB, score = 1
测试数据 #22: Accepted, time = 0 ms, mem = 556 KiB, score = 1
测试数据 #23: Accepted, time = 0 ms, mem = 560 KiB, score = 1
测试数据 #24: Accepted, time = 0 ms, mem = 560 KiB, score = 1
测试数据 #25: Accepted, time = 0 ms, mem = 560 KiB, score = 1
测试数据 #26: Accepted, time = 0 ms, mem = 560 KiB, score = 1
测试数据 #27: Accepted, time = 0 ms, mem = 556 KiB, score = 1
测试数据 #28: Accepted, time = 0 ms, mem = 564 KiB, score = 1
测试数据 #29: Accepted, time = 0 ms, mem = 560 KiB, score = 1
测试数据 #30: Accepted, time = 0 ms, mem = 560 KiB, score = 1
测试数据 #31: Accepted, time = 0 ms, mem = 560 KiB, score = 1
测试数据 #32: Accepted, time = 0 ms, mem = 560 KiB, score = 1
测试数据 #33: Accepted, time = 0 ms, mem = 560 KiB, score = 1
测试数据 #34: Accepted, time = 15 ms, mem = 560 KiB, score = 1
测试数据 #35: Accepted, time = 0 ms, mem = 560 KiB, score = 1
测试数据 #36: Accepted, time = 0 ms, mem = 560 KiB, score = 1
测试数据 #37: Accepted, time = 0 ms, mem = 560 KiB, score = 1
测试数据 #38: Accepted, time = 0 ms, mem = 560 KiB, score = 1
测试数据 #39: Accepted, time = 0 ms, mem = 564 KiB, score = 1
测试数据 #40: Accepted, time = 15 ms, mem = 560 KiB, score = 1
测试数据 #41: Accepted, time = 15 ms, mem = 556 KiB, score = 1
测试数据 #42: Accepted, time = 0 ms, mem = 560 KiB, score = 1
测试数据 #43: Accepted, time = 0 ms, mem = 560 KiB, score = 1
测试数据 #44: Accepted, time = 0 ms, mem = 560 KiB, score = 1
测试数据 #45: Accepted, time = 15 ms, mem = 560 KiB, score = 1
测试数据 #46: Accepted, time = 15 ms, mem = 560 KiB, score = 1
测试数据 #47: Accepted, time = 0 ms, mem = 560 KiB, score = 1
测试数据 #48: Accepted, time = 0 ms, mem = 560 KiB, score = 1
测试数据 #49: Accepted, time = 0 ms, mem = 556 KiB, score = 1
测试数据 #50: Accepted, time = 15 ms, mem = 560 KiB, score = 1
测试数据 #51: Accepted, time = 0 ms, mem = 560 KiB, score = 1
测试数据 #52: Accepted, time = 0 ms, mem = 560 KiB, score = 1
测试数据 #53: Accepted, time = 0 ms, mem = 560 KiB, score = 1
测试数据 #54: Accepted, time = 0 ms, mem = 560 KiB, score = 1
测试数据 #55: Accepted, time = 0 ms, mem = 564 KiB, score = 1
测试数据 #56: Accepted, time = 0 ms, mem = 560 KiB, score = 1
测试数据 #57: Accepted, time = 0 ms, mem = 560 KiB, score = 1
测试数据 #58: Accepted, time = 0 ms, mem = 560 KiB, score = 1
测试数据 #59: Accepted, time = 0 ms, mem = 560 KiB, score = 1
测试数据 #60: Accepted, time = 0 ms, mem = 560 KiB, score = 1
测试数据 #61: Accepted, time = 0 ms, mem = 560 KiB, score = 1
测试数据 #62: Accepted, time = 0 ms, mem = 560 KiB, score = 1
测试数据 #63: Accepted, time = 0 ms, mem = 560 KiB, score = 1
测试数据 #64: Accepted, time = 15 ms, mem = 560 KiB, score = 1
测试数据 #65: Accepted, time = 15 ms, mem = 560 KiB, score = 1
测试数据 #66: Accepted, time = 0 ms, mem = 560 KiB, score = 1
测试数据 #67: Accepted, time = 0 ms, mem = 560 KiB, score = 1
测试数据 #68: Accepted, time = 0 ms, mem = 560 KiB, score = 1
测试数据 #69: Accepted, time = 0 ms, mem = 560 KiB, score = 1
测试数据 #70: Accepted, time = 0 ms, mem = 560 KiB, score = 1
测试数据 #71: Accepted, time = 0 ms, mem = 556 KiB, score = 1
测试数据 #72: Accepted, time = 0 ms, mem = 560 KiB, score = 1
测试数据 #73: Accepted, time = 0 ms, mem = 560 KiB, score = 1
测试数据 #74: Accepted, time = 0 ms, mem = 560 KiB, score = 1
测试数据 #75: Accepted, time = 0 ms, mem = 560 KiB, score = 1
测试数据 #76: Accepted, time = 0 ms, mem = 556 KiB, score = 1
测试数据 #77: Accepted, time = 0 ms, mem = 564 KiB, score = 1
测试数据 #78: Accepted, time = 15 ms, mem = 560 KiB, score = 1
测试数据 #79: Accepted, time = 15 ms, mem = 560 KiB, score = 1
测试数据 #80: Accepted, time = 15 ms, mem = 556 KiB, score = 1
测试数据 #81: Accepted, time = 15 ms, mem = 556 KiB, score = 1
测试数据 #82: Accepted, time = 0 ms, mem = 560 KiB, score = 1
测试数据 #83: Accepted, time = 0 ms, mem = 560 KiB, score = 1
测试数据 #84: Accepted, time = 15 ms, mem = 560 KiB, score = 1
测试数据 #85: Accepted, time = 0 ms, mem = 560 KiB, score = 1
测试数据 #86: Accepted, time = 0 ms, mem = 560 KiB, score = 1
测试数据 #87: Accepted, time = 0 ms, mem = 564 KiB, score = 1
测试数据 #88: Accepted, time = 0 ms, mem = 560 KiB, score = 1
测试数据 #89: Accepted, time = 0 ms, mem = 564 KiB, score = 1
测试数据 #90: Accepted, time = 0 ms, mem = 560 KiB, score = 1
测试数据 #91: Accepted, time = 0 ms, mem = 560 KiB, score = 1
测试数据 #92: Accepted, time = 0 ms, mem = 560 KiB, score = 1
测试数据 #93: Accepted, time = 0 ms, mem = 564 KiB, score = 1
测试数据 #94: WrongAnswer, time = 0 ms, mem = 560 KiB, score = 0
测试数据 #95: Accepted, time = 0 ms, mem = 560 KiB, score = 1
测试数据 #96: Accepted, time = 0 ms, mem = 560 KiB, score = 1
测试数据 #97: Accepted, time = 0 ms, mem = 564 KiB, score = 1
测试数据 #98: Accepted, time = 0 ms, mem = 564 KiB, score = 1
测试数据 #99: Accepted, time = 0 ms, mem = 560 KiB, score = 1
WrongAnswer, time = 225 ms, mem = 564 KiB, score = 99
**
```
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int t,n,ans;
int num[10],c[15];
int chupai(){
int i,tot=0;
memset(num,0,sizeof(num));
for(i=0;i<=13;i++)
num[c[i]]++;
while(num[4]&&num[2]>1){
num[4]--;
num[2]-=2;
tot++;
}
while(num[4]&&num[1]>1){
num[4]--;
num[1]-=2;
tot++;
}
while(num[4]&&num[2]==1){
num[4]--;
num[2]--;
tot++;
}
while(num[3]&&num[2]>=1){
num[3]--;
num[2]--;
tot++;
}
while(num[3]&&num[1]>=1){
num[3]--;
num[1]--;
tot++;
}
return tot+num[1]+num[2]+num[3]+num[4];
}
void dfs(int step){
if(step>ans) return;
int temp=chupai();
if(temp+step<ans){
ans=temp+step;
}
for(int i=2;i<=13;i++){
int j=i;
while(c[j]>=3)
j++;
if(j-i>=2){
for(int j2=i+1;j2<=j-1;j2++){
for(int k=i;k<=j2;k++)
c[k]-=3;
dfs(step+1);
for(int k=i;k<=j2;k++)
c[k]+=3;
}
}
}
for(int i=2;i<=13;i++){
int j=i;
while(c[j]>=2)
j++;
if(j-i>=3){
for(int j2=i+2;j2<=j-1;j2++){
for(int k=i;k<=j2;k++)
c[k]-=2;
dfs(step+1);
for(int k=i;k<=j2;k++)
c[k]+=2;
}
}
}
for(int i=2;i<=13;i++){
int j=i;
while(c[j]>=1)
j++;
if(j-i>=5){
for(int j2=i+4;j2<=j-1;j2++){
for(int k=i;k<=j2;k++)
c[k]-=1;
dfs(step+1);
for(int k=i;k<=j2;k++)
c[k]+=1;
}
}
}
}
int main(){
freopen("in.in","r",stdin);
int i,j;
cin>>t>>n;
for(i=1;i<=t;i++){
ans=25;
memset(c,0,sizeof(c));
for(j=1;j<=n;j++){
int a,b;
cin>>a>>b;
if(a==1){
a=13;
}
else if(a) a--;
c[a]++;
}
dfs(0);
printf("%d\n",ans);
}
return 0;
}
```
0 条评论
信息
- ID
- 1980
- 难度
- 8
- 分类
- (无)
- 标签
- 递交数
- 2591
- 已通过
- 352
- 通过率
- 14%
- 被复制
- 13
- 上传者