【Henu ACM Round#18 D】Looksery Party
2024-09-30 02:27:33
【链接】 我是链接,点我呀:)
【题意】
在这里输入题意
【题解】
假设现在每个人收到的信息条数存在cnt里面
那个人猜的条数为target
则如果cnt[i]==target[i]
则我们就让第i个人来就好了。
因为s[i][i]=1恒成立。
所以第i个人它的cnt个数肯定递增了。
因此第i个人的cnt值和target值肯定再也不会相同了。
(其他人如果来的话,只会让这个人的cnt值越来越大,离target越来越远
所以如果对每个人都这么做的话。
最后肯定可以让所有人的cnt值都和target值不一样。
【代码】
#include <bits/stdc++.h>
using namespace std;
const int N = 100+10;
int n,cnt[N],target[N],bo[N+10];
char s[N][N];
int main(){
#ifdef LOCAL_DEFINE
freopen("rush_in.txt", "r", stdin);
#endif
ios::sync_with_stdio(0),cin.tie(0);
cin >> n;
for (int i = 1;i <= n;i++) cin >> (s[i]+1);
for (int i = 1;i <= n;i++) cin >> target[i];
while (1){
int ok = 0;
for (int i = 1;i <= n;i++)
if (cnt[i]==target[i]){
bo[i] = 1;
for (int j = 1;j <= n;j++)
{
int k = s[i][j]-'0';
cnt[j]+=k;
}
ok = 1;
}
if (!ok) break;
}
int num = 0;
for (int i = 1;i <= n;i++) num+=bo[i];
cout<<num<<endl;
for (int i = 1;i <= n;i++)
if (bo[i]){
cout<<i<<' ';
}
return 0;
}
最新文章
- [Android Tips] 21. Regex Named Groups in Android
- 洛谷P2409 Y的积木
- 九个uname命令获取Linux系统详情的实例
- C++析构函数定义为虚函数(转载)
- Redis 宣言(Redis Manifesto)
- Editplus 中将文本换行替换为<;p>;标签的正则表达式
- 【转】怎样创建一个Xcode插件(Part 2)
- VBA 开发学习--基础语法
- ZOJ 3609 求逆元
- 使用Stardict命令行版本sdcv
- python高阶函数式编程
- Java自定义异常类以及异常拦截器
- mongoose一看就会的基本操作
- [面试题]vi/vim快捷键及面试题系列
- [Asp.net]web.config customErrors 如何设置?
- Qt Installer Framework 使用说明(三)
- python中web应用与mysql数据库交互
- nginx+tomat https ssl 部署 完美解决方案
- BigDecimalUtils BigDecimal加减乘除
- (N)IO Frameworks in Java