您当前的位置: 首页 > 

*DDL_GzmBlog

暂无认证

  • 2浏览

    0关注

    605博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

[Acwing*] 1211. 蚂蚁感冒 思维好题

*DDL_GzmBlog 发布时间:2021-11-04 22:48:17 ,浏览量:2

前言

算是脑经急转弯了,hh 传送门 :

思路

这题反而不可以想太细,什么的,其实我们完全不用考虑碰撞

之后的掉头过程,因为如果把碰撞改为穿过 也是合情合理的

因此我们计算答案只需要 a n s = l e f t + r i g h t + 1 ans = left + right+1 ans=left+right+1 第一只左边向右的数量,右边向左的数量,和本身

这样子我们就可以算出答案了

(其实有的时候,不要被题目迷惑了)

CODE
#include 
using namespace std;
#define ll long long
#define endl '\n'
#define px first
#define py second
#define pb push_back
typedef pair pii;
int dxy[4][2] = {{-1,0},{0,1},{1,0},{0,-1}};
const int N  = 210;

struct union_find_set{
    int n,p[N];

    void init(int N)
    {
        n = N;
        for(int i=1;i>n;
	int t;cin>>t;
	int left = 0;
	int right = 0 ;
	
	for(int i=1;i>x;
		if(abs(x) 0) right++;
		///左边的向右走
		
		//右边的向左走
		if(abs(x) > abs(t) && x            
关注
打赏
1657615554
查看更多评论
0.1206s