首页 > 其他分享 >A. Computer Game【dfs诈骗】

A. Computer Game【dfs诈骗】

时间:2023-03-10 23:56:47浏览次数:35  
标签:cnt const int dfs Game Computer include

A. Computer Game

image
image

代码

点击查看代码
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<cctype>
using namespace std;

#define X first
#define Y second

typedef pair<int,int> pii;
typedef long long LL;
const char nl = '\n';
const int N = 1e5+10;
const int M = 2e5+10;
int n,m;
int cnt[110];
void solve(){
	bool f = 1;
	memset(cnt,0,sizeof cnt);
	cin >> n;
	string s;
	for(int i = 1; i <= 2; i ++ ){
		cin >> s;
		for(int j = 0; j < n; j ++ ){
			if(s[j] == '1')cnt[j + 2] ++;
			if(i == 2 && cnt[j + 2] == 2){
				f = 0;
				break;
			}
		}
	}
	if(f)cout << "YES" << nl;
	else cout << "NO" << nl;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);

	int T;
	cin >> T;
	while(T --){
		solve();
	}
}

小结

  1. 惯性思维直接dfs导致tle
  2. 注意题目特性只有两行
  3. 注意不要重复定义,否则全局变量变局部变量
  4. 注意dfs最好没有返回值,用f记录一下是否能抵达就好,有返回值会特别乱

标签:cnt,const,int,dfs,Game,Computer,include
From: https://www.cnblogs.com/J-12045/p/17205023.html

相关文章

  • Games101-Cp1-Transformation
    最近为了求职重新开始把图形学相关的内容重新系统的学习,先把Games101的内容入门,然后把虎书相关的内容补充。Transformation矩阵变换可以对不同坐标系之间进行转换,在这个......
  • Mongodb存储二进制文件GridFS空间复用测试
    Oracle可以存储二进制文件,测试后发现lob字段再数据delete后表空间不能被复用,考虑将数据存储在mongodb中,mongodb存在GridFS,测试GridFS是否也存在相同的情况mongofiles命令介......
  • 爆肝两万字,详解fastdfs分布式文件系统
    1.学习目标2.简介技术论坛:http://bbs.chinaunix.net/forum-240-1.html资源地址:https://sourceforge.net/projects/fastdfs/源码地址:https://github.com/happyfish100......
  • dfs+剪枝
    题目:给定两个整数n,x。你可以对x进行任意次以下操作:选择x的一位数字y,将x替换为x×y。请你计算通过使用上述操作,将x变为一个n位数字(不含前导0),所需要的最......
  • Middle Duplication (CFD2E) (贪心,中序树,字典序大小.dfs)
      大佬的思路:  #include<bits/stdc++.h>usingnamespacestd;intn,k,l[200010],r[200010],pos[200010];charc[200010];vector<int>seq;voidprecalc(i......
  • 天梯赛练习题L3-001 凑零钱(dfs 爆搜)
    https://pintia.cn/problem-sets/994805046380707840/exam/problems/994805054207279104题目大意:给定n个硬币,总共需要我们凑出m块钱。问我们能凑出的硬币的最小字典序......
  • CF207C3 Game with Two Trees 题解
    脑子不够,科技来凑。不过好像也没有用多么高级的科技……首先这个题目很坏,它让你翻转\(S_{t_2}\)。即从\(t_2\)某个节点往下走到另一个节点的路径所表示的字符串。这个......
  • AcWing 165. 小猫爬山(dfs)
    https://www.acwing.com/problem/content/167/一共N只小猫,每个缆车最大承重量为W。N只小猫的重量分别是C1、C2……CN。当然,每辆缆车上的小猫的重量之和不能超过W。......
  • 【DFS】LeetCode 剑指 Offer 07. 重建二叉树
    题目链接剑指Offer07.重建二叉树思路递归建树,思路与【DFS】LeetCode105.从前序与中序遍历序列构造二叉树相同。代码classSolution{publicTreeNodebuild......
  • [qoj4820]Kitten's Computer
    为了方便,以下位运算中均省略\(\and\)将\(a_{2}\)的每一位拆开,对于第\(i\)位,将该位乘\(a_{1}\)的结果放到\(a_{A_{i}}\)上具体的,将该位单独取出放在最低位,并倍增使其余位......