BZOJ2102 : [Usaco2010 Dec]The Trough Game
The Game Dec
2023-09-11 14:15:04 时间
暴力枚举答案然后检验。
#include<cstdio> int n,m,i,j,k,a[100],b[100],cnt,ans;char s[20]; int main(){ for(scanf("%d%d",&n,&m);i<m;i++)for(scanf("%s%d",s,&b[i]),j=0;j<n;j++)if(s[j]=='1')a[i]|=1<<j; for(i=0;i<(1<<n);i++){ for(k=1,j=0;j<m;j++)if(__builtin_popcount(i&a[j])!=b[j]){k=0;break;} if(k){cnt++;if(cnt>1)break;ans=i;} } if(cnt==1)for(i=0;i<n;i++)putchar(48+(ans>>i&1));else puts(cnt?"NOT UNIQUE":"IMPOSSIBLE"); return 0; }
相关文章
- 新建maven指定jdk版本-eclipse新建maven项目报错The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path的解决方案
- 【RMAN】RMAN-05001: auxiliary filename conflicts with the target database
- 【异常】[ERROR] The cloud assistant is not installed on the ECS, or the cloud assistant is unavailable. cloudassistant is uninstall
- Eclipse和Maven的结合使用--Please make sure the -vm option in eclipse.ini
- [PWA] Check Online Status by using the NavigatorOnLine API
- [React Native] Using the WebView component
- [Angular 2] Using a Value from the Store in a Reducer
- [React] Manipulate the DOM with React refs
- [NgRx] Setting up NgRx Router Store and the Time-Travelling Debugger
- [Performance] Optimize Paint and Composite for the website
- [ReactVR] Render Custom 3D Objects Using the Model Component in React VR
- 【Codeforces Round #185 (Div. 2) C】The Closest Pair
- 【 Codeforces Round #430 (Div. 2) A 】 Kirill And The Game
- Unexpected XML declaration. The XML declaration must be the first node in the document and no white
- 【已解决】RuntimeError: The following handlers are available to decode the pixel data however they are
- 【问题解决】The connection to the server localhost:8080 was refused
- 问题解决:The connection to the server xxxxx:6443 was refused - did you specify the right host or port?
- apollo install ERROR: An error occurred during the fetch of repository ‘zlib‘:
- java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.
- 存在隐患 : 3 racks are required for the erasure coding policies: RS-6-3-1024k. The number of racks is on
- flutter Error:Cannot run with sound null safety, the following dependencies don‘t support null safe
- 成功解决 ERROR: An error occurred while performing the step: “Building kernel modules“. See /var/log/nv
- Denoising Diffusion GAN:Tackling the Generative Learning Trilemma with Denoising Diffusion GANs