UVa 101 - The Blocks Problem

H3C交换机S-MLAG实战:如何用bond4模式实现服务器高可用(附避坑指南) 本文详细介绍了H3C交换机S-MLAG技术与服务器bond4模式的实战配置,帮助实现跨设备链路聚合的服务器高可用方案。通过解析S-MLAG技术优势、bond4模式选择、关键配置步骤及常见问题排查,提供了一套完整的避坑指南和优化建议,适用于企业级网络架构的高可用需求。 阅读详情

模拟栈,这个题并不难,注意a、b积木相同时情况的处理就可以,但至今都不明白当时为什么RE了那么多遍,数组cn开小了就RE,但按题目说最多开个cn[25][25]的数组就足够了,但我开到100多还是RE,结果一下开到200多就AC了,至今不知道是为什么,求大神解释啊~~~

#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
struct blocks
{
    int m,n;
    char a[10];
    char b[10];
} AI[1000+5];
int cn[250+5][250+5],ct[250+5];  // 数组?
int sfind(int num,int m)      //查找相应积木
{
    for(int i=0; i<num; i++)
        for(int j=0; j<ct[i]; j++)
            if(cn[i][j]==m)
                return i;
    return 0;
}
int change(int flagm,int m)   //将相应积木放回原处
{
    for(int i=ct[flagm]-1; i>=0; i--)
        if(cn[flagm][i]!=m)
        {
            int ggt=cn[flagm][i];
            cn[ggt][ct[ggt]++]=cn[flagm][i];
            ct[flagm]--;
        }
        else break;
    return 0;
}
int monto(int m,int n,int num)   {
    int flagm,flagn;
    flagm=sfind(num,m);
    flagn=sfind(num,n);
    change(flagm,m);
    change(flagn,n);
    cn[flagn][ct[flagn]++]=cn[flagm][--ct[flagm]];
    return 0;
}
int mover(int m,int n,int num)
{
    int flagm,flagn;
    flagm=sfind(num,m);
    flagn=sfind(num,n);
    change(flagm,m);
    cn[flagn][ct[flagn]++]=cn[flagm][--ct[flagm]];
    return 0;
}
int ponto(int m,int n,int num)
{
    int flagm,flagn,flaga;
    flagn=sfind(num,n);
    flagm=sfind(num,m);
    change(flagn,n);
    for(int i=0; i<ct[flagm]; i++)
        if(m==cn[flagm][i])
        {
            flaga=i;
            break;
        }
    for(int i=flaga; i<ct[flagm]; i++)
        cn[flagn][ct[flagn]++]=cn[flagm][i];
    ct[flagm]-=ct[flagm]-flaga;
    return 0;
}
int pover(int m,int n,int num)
{
    int flagm,flagn,flaga;
    flagn=sfind(num,n);
    flagm=sfind(num,m);
    for(int i=0; i<ct[flagm]; i++)
        if(m==cn[flagm][i])
        {
            flaga=i;
            break;
        }
    for(int i=flaga; i<ct[flagm]; i++)
        cn[flagn][ct[flagn]++]=cn[flagm][i];
    ct[flagm]-=ct[flagm]-flaga;
    return 0;
}
int main()
{
#ifdef test
    freopen("sample.txt","r",stdin);
#endif
    int num;
    while(scanf("%d",&num)!=EOF)
    {
        int count=0;
        while(1)
        {
            getchar();
            scanf("%s",AI[count].a);
            if(strcmp(AI[count].a,"quit")==0)
                break;
            scanf(" %d %s %d",&AI[count].m,AI[count].b,&AI[count].n);
            count++;
        }
        for(int i=0; i<num; i++)
        {
            cn[i][0]=i;
            ct[i]=1;
        }
        for(int i=0; i<count; i++)
        {
            int flagm,flagn;
            flagn=sfind(num,AI[i].n);
            flagm=sfind(num,AI[i].m);
            if(flagm==flagn||AI[i].n==AI[i].m)
                continue;
            //四种情况
            if(strcmp(AI[i].a,"move")==0&&strcmp(AI[i].b,"onto")==0)
                monto(AI[i].m,AI[i].n,num);
            else if(strcmp(AI[i].a,"move")==0&&strcmp(AI[i].b,"over")==0)
                mover(AI[i].m,AI[i].n,num);
            else if(strcmp(AI[i].a,"pile")==0&&strcmp(AI[i].b,"onto")==0)
                ponto(AI[i].m,AI[i].n,num);
            else if(strcmp(AI[i].a,"pile")==0&&strcmp(AI[i].b,"over")==0)
                pover(AI[i].m,AI[i].n,num);
        }
        for(int i=0; i<num; i++)
        {
            printf("%d:",i);
            for(int j=0; j<ct[i]; j++)
                printf(" %d",cn[i][j]);
            puts("");
        }
    }
    return 0;
}


一个严谨的STM32串口DMA发送&接收(1.5Mbps波特率)机制 本文描述串口DMA收/发机制设计,及STM32串口DMA收/发实现。 阅读详情

相关推荐

nmap、X-Scan漏洞扫描和Metasploit中用永恒之蓝漏洞入侵靶机并上传冰河

利用nmap、X-Scan扫描靶机的漏洞,在Metasploit中用扫描出的永恒之蓝漏洞入侵靶机,建立连接后上传冰河木马控制靶机,最后用冰河陷阱清除靶机的冰河木马,记一次完整的入侵控制实验。

m0_59302403的博客 4408

UVA 101 The Blocks Problem

UVA 101 The Blocks Problem              题目链接 题目大意:      给出数字n,表示有n个方块,每次按照操作步骤移动方块,根据不同的指令,执行不同的操作。             1.move a onto b,把a和b上面的方块都放回原来位置,然后把a放到b上面;             2.move a over b,把a上面的放回原处,然后

---小菜鸟--- 191

智能车图像处理0-变量释义

这篇文章主要讲述智能车图像处理中,各篇主要变量的含义。如果在看具体分析代码时感到困惑,可以在本篇文章中查询,辅助理解。

taiyuezyh的博客 3680

uva 101 The Blocks Problem (模拟)

uva 101  The Blocks Problem Background  Many areas of Computer Science use simple, abstract domains for both analytical and empirical studies. For example, an early AI study of planning and

总有那么一群人喜欢盯着我的博客看,估计这是他们见过最长的博客名,我必须得告诉他们博客名最长可以写多长 613

Arcgis使用NDVI值遥感反演叶面积指数(LAI)

经验模型反演操作不难,主要是要多看文献,了解公式。本文中的公式我也不清楚是哪个作物的NDVI和LAI的关系(别人提供的),继续看文献整理吧。后续会在下面罗列更新一下主要公式。

所有专家都曾始于新手 8430

【DaVinci Configurator专题】-2-将CAN 2.0或CANFD Matrix的Arxml/DBC文件导入到CFG

共9页 目录 1 打开DaVinci Configurator,导入Arxml文件 2 解决导入Arxml文件后可能会出现的一些错误 3 验证CFG的配置 4 根据CFG的配置生成代码 5 结尾 <--返回「实战篇」博文-总目录--> <--返回「Autosar从入门到精通-实战篇」专栏主页--> 关键词: Open the Input Files Assistant Complete update process Update ECU configurati

「汽车电子助手」的博客 6125

UVa 101 - The Blocks Problem解题报告

模拟类型的题,很麻烦。特别考验细心程度。虽然调试了很久,但是倒也学会了不少的调试技巧。 注意:无需考虑将积木放回原位时原位被占的情况,因为没有任何一个操作可以把积木放在空的位置上,因此也不可能出现在第i个位置上,第i个积木的下面有其它积木的情况。 思路:用一个二维数组模拟积木堆,用结构数组pos存储每个积木的x,y坐标,每个积木的代号正好与结构数组的下标形成一一映射。再用len数组存储存储每个

Yonah潇的专栏 893

使用rknn进行facenet部署

修改facenet网络的forward函数代码。

如果想成为中心,那么就到中心去吧。 1044

UVa 101 The Blocks Problem

本文分析了机器人手臂在方块世界中的操作模拟问题。题目给出了五种操作命令,包括移动单个方块或整个堆栈到指定位置。解题思路采用二维数组存储方块堆栈,实现了归位操作、位置查找以及四种移动操作。算法时间复杂度为O(mn),空间复杂度O(n²)。代码通过初始化状态、处理命令和输出结果三个步骤,准确模拟了方块操作过程。关键点在于理解每种操作的具体含义并正确处理无效命令,保证程序的正确性和鲁棒性。

寂静山林 600

手把手教你学simulink实例--基于Simulink的航空发动机控制系统设计与仿真

航空发动机是飞机的核心动力装置,其性能直接影响飞行器的安全性、经济性和可靠性。现代航空发动机控制系统需要具备高精度、快速响应和强鲁棒性的特点,以适应复杂的飞行环境和任务需求。本项目旨在使用MATLAB/Simulink平台,设计并实现一种适用于涡扇发动机的闭环控制系统,通过调节燃油流量、压气机叶片角度等控制变量,确保发动机在不同工况下稳定运行,并满足推力需求。

MHD0815的博客 275

【Halcon-2D测量】add_metrology_object_rectangle2_measure 函数功能(用于向2D计量模型中添加旋转矩形(rectangle2类型)计量对象)

HALCON算子add_metrology_object_rectangle2_measure解析摘要 该算子是HALCON 2D计量模块的核心算子,用于添加旋转矩形计量对象并配置测量参数。主要功能包括:定义旋转矩形几何轮廓(中心坐标、主轴角度、长短半长);生成垂直于矩形边界的测量区域;设置边缘提取预处理参数(高斯平滑、振幅阈值)。关键注意事项:MeasureLength1必须小于矩形长短半长;角度参数Phi需使用弧度单位;多线程需同步模型句柄。该算子适用于方形螺母、PCB板边框等矩形零件的精密测量,需与a

weixin_45590420的博客 1223

uva 101 the blocks problem

uva老不让过…… 注意: move a onto b where a and b areblock numbers, puts block a onto block b afterreturning any blocks that are stacked on top of blocks a and b to their initial positions.

LeanCloud-lzwjava 890

Devexpress16.2.6破解工具

Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具

UVa Problem 101 - The Blocks Problem

[cpp] view plaincopyprint? // UVa Problem 101 - The Blocks Problem   // Verdict: Accepted   // Submission Date: 2011-10-16   // UVa Run Time: 0.020s   //   // 版权所有(C)2011,邱秋。metaphysis # y

xujiangang_mmi的专栏 368

怀旧版电脑GBC模拟器

再现原版GBC掌机的界面,电脑运行连游戏界面都一样大小,很怀旧,很真实,(英文版)强烈推荐,很小的文件,很难才找到的。

SAP B1中文培訓教材_SDK

公司内部培训资料,对开发工具 ,DIAPI, UIAPI,Add-ON有详细解说

UVa 101 The Blocks Problem Vector基本操作

UVa 101 The Blocks Problem一道纯模拟题 The Problem  The problem is to parse a series of commands that instruct a robot arm in how to manipulate blocks that lie on a flat table. Initially there are nbl

SilverNebula的博客 508

假人有限元模型

假人模型,车辆碰撞假人有限元模型,适合做乘员安全的研究者利用

UVA101 The Blocks Problem

目录题目输入输出样例输入样例输出代码后记 题目 Many areas of Computer Science use simple, abstract domains for both analytical and empirical studies. For example, an early AI study of planning and robotics (STRIPS) used a block world in which a robot arm performed tasks involvin

夏午Sharve的博客? 178

UVa101 (木块问题 The Blocks Problem)

1、题目大意 题目链接UVa101 2、解题思路 开一个二维数组,直接进行模拟即可。 3、参考代码 #include&amp;lt;iostream&amp;gt; #include&amp;lt;string&amp;gt; #include&amp;lt;cstring&amp;gt; using namespace std; int ans[30][30]; int find_block(int s[30][30], int a) ...

Armstrong的博客 1019

UVA101 The Blocks Problem 题解

题目链接:https://www.luogu.org/problemnew/show/UVA101 这题码量稍有点大。。。 分析: 这道题模拟即可。因为考虑到所有的操作vector可最快捷的实现,所以数组动态vector。每一种情况分别考虑。 其他的见代码注释 部分过长的注释防在这里,请对照序号到代码中查看。 ①:wa意为a的位置,记录当前...

dianwonin4433的博客 143

UVA101 HDU1612 POJ1208 The Blocks Problem【模拟】

问题链接:UVA101 HDU1612 POJ1208 The Blocks Problem。 问题简述:参见上述链接。 问题分析:这是一个模拟题,程序过程都是套路。 程序说明: 程序中用到了STL的容器类vector。 开始的时候,编写的程序在UVA和POJ中都AC,可是在HDU中是“Presentation Error”。问题出在输出格式上,针对HDU另...

weixin_34198762的博客 95

Uva 101 - The Blocks Problem

The Blocks Problem Time Limit: 1000MS   Memory Limit: 10000KB   64bit IO Format: %I64d & %I64u [Submit]   [Go Back]   [Status]   Description Many areas of Computer Sc

小G的ACM之路 825

UVa101 - The Blocks Problem

桌上放有若干“blocks”      Figure: Initial Blocks World 初始位置如图所示;有五种操作: (1)move a onto b :先将a和b之上的所有block都复位(恢复为initial状态),然后把a放在b上; (2)move a over b :先将a之上的所有block都复位,然后把a放在b所在的堆顶端; (3

打酱油 747

UVA101 【The Blocks Problem】

一个大模拟!!! 总的来说就是碰到move就要把a上面的全部放回原处。 如果碰到onto就要把b上面的全部放到原处。 因为move是只移动a一个,所以a上面的要归位,而pile是移一堆,所以不用。 onto是要和b贴在一起,所以b上面的要归位,而over是上方,不需要直接接触,所以不用。。 思路就是用栈来模拟,一开始就是n个栈。每个栈里都是一个元素,然后按照指令移,在这个栈里pop()掉...

arex71991的博客 131

The Blocks Problem UVA - 101

The Blocks Problem UVA - 101题目描述 Many areas of Computer Science use simple, abstract domains for both analytical and empirical studies. For example, an early AI study of planning and robotics (STRIPS

退役的铜牌狗 680
上一篇: UVa 10137 - The Trip
下一篇: UVa 10152 - ShellSort
GooMaple
博客等级 码龄14年 79粉丝 197原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值