1029 False coin
来源:互联网 发布:七年级网络阅卷 编辑:程序博客网 时间:2024/05/03 07:41
wa了n次,枚举哪个硬币是不同的,带入条件验证是否有矛盾
要注意:
对于>和<,没有出现在两边的肯定是真的
对于=,出现在两边的肯定是真的
- //3463503_AC_32MS_292K
- #include<iostream>
- #include<string>
- #include<sstream>
- using namespace std;
- #define MAXN 100
- struct Node
- {
- bool a[MAXN],b[MAXN];
- };
- int i,j,n,k,t,pi,m,test,ans;
- string s;
- char c;
- Node wit[MAXN];
- bool use[MAXN];
- bool temp[MAXN];
- int fit(int x)
- {
- int i,ret=0;
- for (i=0;i<m;++i)
- {
- if (!(wit[i].a[x]&&!wit[i].b[x]))
- {
- break;
- }
- }
- if (i==m)
- {
- ret++;
- }
- for (i=0;i<m;++i)
- {
- if (!(wit[i].b[x]&&!wit[i].a[x]))
- {
- break;
- }
- }
- if (i==m)
- {
- ret++;
- }
- return ret;
- }
- int main()
- {
- //freopen("d:/in.txt","r",stdin);
- test=0;
- while (cin>>n>>k&&!(n==0&&k==0))
- {
- test++;
- memset(use,true,n);
- m=0;
- for (i=0;i<k;++i)
- {
- getchar();
- getline(cin,s);
- stringstream ss(s);
- ss>>pi;
- cin>>c;
- switch (c)
- {
- case '=':
- for (j=0;j<pi*2;++j)
- {
- ss>>t;
- use[t-1]=false;
- }
- break;
- case '<':
- memset(temp,false,n);
- memset(wit[m].a,false,n);
- memset(wit[m].b,false,n);
- for (j=0;j<pi;++j)
- {
- ss>>t;
- wit[m].a[t-1]=true;
- temp[t-1]=true;
- }
- for (j=0;j<pi;++j)
- {
- ss>>t;
- wit[m].b[t-1]=true;
- temp[t-1]=true;
- }
- m++;
- for (j=0;j<n;++j)
- {
- if (!temp[j])
- {
- use[j]=false;
- }
- }
- break;
- case '>':
- memset(temp,false,n);
- memset(wit[m].a,false,n);
- memset(wit[m].b,false,n);
- for (j=0;j<pi;++j)
- {
- ss>>t;
- wit[m].b[t-1]=true;
- temp[t-1]=true;
- }
- for (j=0;j<pi;++j)
- {
- ss>>t;
- wit[m].a[t-1]=true;
- temp[t-1]=true;
- }
- m++;
- for (j=0;j<n;++j)
- {
- if (!temp[j])
- {
- use[j]=false;
- }
- }
- break;
- }
- }
- ans=-1;
- for (i=0;i<n;++i)
- {
- if (use[i])
- {
- if (fit(i)!=0)
- {
- if (ans!=-1)
- {
- ans=-1;
- break;
- }
- else
- {
- ans=i;
- }
- }
- }
- }
- cout<<ans+1<<endl;
- }
- return 0;
- }
- 1029 False coin
- 1029 False coin
- poj 1029 False Coin
- 1029 False coin
- POJ 1029 False coin
- poj 1029 False coin
- poj 1029 False coin
- poj 1029 False coin
- POJ-1029-False coin
- hdu 1029 False coin
- POJ 1029 False coin
- False coin - POJ 1029
- POJ 1029 False coin
- POJ 1029-False coin
- POJ 1029 False coin
- POJ 1029--False coin
- False coin
- False coin
- VC++获取文件修改时间
- oracle 创建数据库表 如果此表存在则删除后再重建
- myeclipse快捷键
- S3C2410的RTC驱动分析
- 一些Eclipse快捷键(超实用)
- 1029 False coin
- 我高中的好友们
- 图解MyEclipse配置struts+hibernate+spring+FreeMarker
- shell中使用sort进行多列排序.
- 小佳弱弱学习——queue队列的简单实现
- 小佳弱弱学习——stack栈的简单实现
- 开机总是进行磁盘检查
- 小佳弱弱学习——tree二叉树的简单实现
- 你必须知道的C#的25个基础概念(附演示)