SCU 4445 Right turn(dfs)题解】的更多相关文章

题目传送门 /* 题意:从原点出发,四个方向,碰到一个点向右转,问多少次才能走出,若不能输出-1 模拟:碰到的点横坐标相等或纵坐标相等,然而要先满足碰到点最近, 当没有转向或走到之前走过的点结束循环.dir数组使得代码精简巧妙 对点离原点排序竟然submit failed,别人的代码有毒! */ #include <cstdio> #include <cstring> #include <algorithm> #include <map> #include…
思路:离散化之后,直接模拟就行,标记vis开三维 代码: #include<iostream> #include<algorithm> #include<cstdio> #include<stdio.h> #include<string.h> #include<queue> #include<cmath> #include<map> #include<set> #include<vector&…
模拟. 每次找一下即将要遇到的那个点,这个数据范围可以暴力找,自己的写的时候二分了一下.如果步数大于$4*n$一定是$-1$. #include<bits/stdc++.h> using namespace std; const int INF = 0x7FFFFFFF; ; ; ; ; int T,n,m; struct P { int x,y; P(,) { x=X; y=Y; } }p[],q[]; bool cmp1(P a,P b) { if(a.x!=b.x) return a.x…
很水的DFS. 为什么放上来主要是为了让自己的博客有一道DFS题解,,, #include<bits/stdc++.h> using namespace std; ][],ans,flag; char sx; void dfs(int x,int y){ ){ flag=; a[x][y]=; dfs(x-,y); dfs(x+,y); dfs(x,y-); dfs(x,y+); dfs(x-,y-); dfs(x+,y-); dfs(x-,y+); dfs(x+,y+); } } int m…
目录 引言 结果填空 1. 签到题 2. 概念题 3. 签到题 4. 签到题 程序题 5. 递增三元组[遍历] 6. 小明的hello[循环] 7. 数位递增[数位dp] 8. 小明家的草地[bfs] 9. 小明的正整数序列[dfs] 10. 好看的节目[结构体排序] 后记 引言 边吃饭边做题,新鲜的题目详解,虽然所有学校的考试时间都不一样,不过本文是在考试刚结束就开始编写了,对我来说是brandnew的. 这是我去年写的博客,今年又出现不少原题: 去年原题部分 结果填空 1. 签到题 问题描述…
6266  取石子游戏 描述 有两堆石子,两个人轮流去取.每次取的时候,只能从较多的那堆石子里取,并且取的数目必须是较少的那堆石子数目的整数倍.最后谁能够把一堆石子取空谁就算赢. 比如初始的时候两堆石子的数目是25和7 25 7 --> 11 7 --> 4 7 --> 4 3 --> 1 3 --> 1 0   选手1取   选手2取   选手1取   选手2取   选手1取 最后选手1(先取的)获胜,在取的过程中选手2都只有唯一的一种取法. 给定初始时石子的数目,如果两个…
题意:三国杀,给定4个白板武将的血量,4个角色轮流行动,每回合行动时如果该人存活则可以选择使阵营不同的角色血量-1,血量为0则死亡.每个人按自己获胜概率最大化行动,如果有多种方案概率相同则等概率选择这些策略,问最后主公.反贼.内奸三个阵营分别获胜的概率 0 < h1 < 40, 0 ≤ h2 < 40, 0 ≤ h3 < 40, 0 ≤ h4 < 40 思路:当前的决策与概率只与血量和当前行动的人有关 注意行动顺序是主公,反贼,忠臣,内奸 其他的具体看代码注释吧 #inclu…
Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 327680/327680 K (Java/Others) Total Submission(s): 1912    Accepted Submission(s): 824 Problem Description Alice and Bob are playing "Gems Fight!": There are Gems of G different colors ,…
bzoj2115,戳我戳我 Solution: 看得题解(逃,我太菜了,想不出这种做法 那么丢个链接 Attention: 板子别写错了 又写错了这次 \(long long\)是左移63位,多了会溢出就会出鬼 Code: //It is coded by Ning_Mew on 5.29 #include<bits/stdc++.h> #define LL long long using namespace std; const int maxn=5e4+7,maxm=1e5+7; int…
There is a company that has N employees(numbered from 1 to N),every employee in the company has a immediate boss (except for the leader of whole company).If you are the immediate boss of someone,that person is your subordinate, and all his subordinat…