标签:ase char width class printf ini term pen exactly
Time Limit: 1000MS | Memory Limit: 10000K | |
Total Submissions: 17203 | Accepted: 5619 |
Description
Input
Output
Sample Input
2 4 8 1 1 1 1 1 3 1 1 5 6 3 3 2 1 1 1
Sample Output
KHOOOOB! HUTUTU!
Source
#include<iostream> #include<cstring> #include<cstdio> #include<queue> #include<stack> #include<vector> #include<algorithm> //#include<cmath> using namespace std; const int INF = 9999999; #define LL long long inline int read(){ int x=0,f=1;char c=getchar(); for(;!isdigit(c);c=getchar()) if(c==‘-‘) f=-1; for(;isdigit(c);c=getchar()) x=x*10+c-‘0‘; return x*f; } int N,M; int T; int a[60]; int sum; int maxr[60]; int re[60]; bool DFS(int st){ if(st==M){return true;} int Minn=INF,tmp; for(int i=1;i<=N;i++){ if(maxr[i]<Minn){ tmp=i; Minn=maxr[i]; } } for(int i=10;i>=1;i--){ if(!re[i]) continue; bool canin; if(N-maxr[tmp]>=i&&N-tmp+1>=i){ canin=true; for(int j=tmp;j<tmp+i;j++){ if(maxr[j]>maxr[tmp]) { canin=false; break; } } if(canin){ for(int j=tmp;j<tmp+i;j++) maxr[j]+=i; re[i]--; if(DFS(st+1)) return true; re[i]++; for(int j=tmp;j<tmp+i;j++) maxr[j]-=i; } } } return false; } int main(){ //freopen(".in","r",stdin); //freopen(".out","w",stdout); T=read(); while(T--){ memset(re,0,sizeof(re)); memset(maxr,0,sizeof(maxr)); memset(a,0,sizeof(a)); sum=0; N=read(),M=read(); for(int i=1;i<=M;i++) a[i]=read(),sum+=(a[i]*a[i]),re[a[i]]++; if(sum!=N*N) {printf("HUTUTU!\n");continue;} if(DFS(0)) printf("KHOOOOB!\n"); else printf("HUTUTU!\n"); } return 0; }
标签:ase char width class printf ini term pen exactly
原文地址:http://www.cnblogs.com/wxjor/p/7044819.html