BZOJ 1028: [JSOI2007]麻将 暴力

1028: [JSOI2007]麻将

Time Limit: 1 Sec

Memory Limit: 256 MB

题目连接

http://www.lydsy.com/JudgeOnline/problem.php?id=1028

Sample Input

9 4
1 1 2 2 3 3 5 5 5 7 8 8 8

Sample Output

6 7 9

HINT

n的范围只有400，所以直接傻暴力就好了

//qscqesze
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <bitset>
#include <vector>
#include <sstream>
#include <queue>
#include <typeinfo>
#include <fstream>
#include <map>
#include <stack>
typedef long long ll;
using namespace std;
//freopen("D.in","r",stdin);
//freopen("D.out","w",stdout);
#define sspeed ios_base::sync_with_stdio(0);cin.tie(0)
#define maxn 500
#define mod 1001
#define eps 1e-9
#define pi 3.1415926
int Num;
//const int inf=0x7fffffff;
const ll inf=999999999;
{
ll x=0,f=1;char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
return x*f;
}
//*************************************************************************************

int a[maxn];
int b[maxn];
vector<int> ans;
int n,m;
int jud()
{
for(int i=1;i<=n;i++)
{
for(int j=1;j<=n;j++)
b[j]=a[j];
int Ans = 0;
if(b[i]>=2)
{
b[i]-=2;
Ans+=2;
for(int j=1;j<=n;j++)
{
Ans+=3*(b[j]/3);
b[j]%=3;
if(b[j]==0)continue;
if(b[j+1]==0||b[j+2]==0)continue;
b[j]--,b[j+1]--,b[j+2]--;
j--;Ans+=3;
}
}
if(Ans==m*3+2)
return 1;
}
return 0;
}
int main()
{
for(int i=1;i<=3*m+1;i++)
{
a[x]++;
}
for(int i=1;i<=n;i++)
{
a[i]++;
if(jud())ans.push_back(i);
a[i]--;
}
if(ans.size()==0){printf("NO\n");}
else
{
sort(ans.begin(),ans.end());
for(int i=0;i<ans.size();i++)
{
if(i!=0) printf(" %d",ans[i]);
else printf("%d",ans[i]);
}
printf("\n");
}
}

posted @ 2015-09-09 19:55  qscqesze  阅读(545)  评论(0编辑  收藏  举报