CodeForces 128A

codeforces 128B String(优先队列求第k小字典序子序列) 题目链接 参考了mz的博客,mznb 题意 求字典序第k小的子序列 思路 巧妙的利用优先队列,先定义一个存子序列和序列最后一位的下标的结构体,将每个元素和下标入栈。然后处理的时候将栈顶元素取出,将k–,判断k是否大于零,如果不是就说明找到了第k大,是就凭他存的下标给他加上下一个元素,这样就能按字典序的顺序取出子序列。 代码 #include<iostream> #include<... 阅读详情

A. Statues
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

In this task Anna and Maria play a game with a very unpleasant rival. Anna and Maria are in the opposite squares of a chessboard (8 × 8): Anna is in the upper right corner, and Maria is in the lower left one. Apart from them, the board has several statues. Each statue occupies exactly one square. A square that contains a statue cannot have anything or anyone — neither any other statues, nor Anna, nor Maria.

Anna is present on the board as a figurant (she stands still and never moves), and Maria has been actively involved in the game. Her goal is — to come to Anna's square. Maria and statues move in turn, Maria moves first. During one move Maria can go to any adjacent on the side or diagonal cell in which there is no statue, or she can stay in the cell where she is. The statues during their move must go one square down simultaneously, and those statues that were in the bottom row fall from the board and are no longer appeared.

At that moment, when one of the statues is in the cell in which the Maria is, the statues are declared winners. At the moment when Maria comes into the cell where Anna has been waiting, Maria is declared the winner.

Obviously, nothing depends on the statues, so it all depends on Maria. Determine who will win, if Maria does not make a strategic error.

Input

You are given the 8 strings whose length equals 8, describing the initial position on the board. The first line represents the top row of the board, the next one — for the second from the top, and so on, the last line represents the bottom row. Each character string matches a single cell board in the appropriate row, and the characters are in the same manner as that of the corresponding cell. If the cell is empty, the corresponding character is ".". If a cell has Maria, then it is represented by character "M". If a cell has Anna, it is represented by the character "A". If a cell has a statue, then the cell is represented by character "S".

It is guaranteed that the last character of the first row is always "A", the first character of the last line is always "M". The remaining characters are "." or "S".

Output

If Maria wins, print string "WIN". If the statues win, print string "LOSE".

Sample test(s)
input
.......A
........
........
........
........
........
........
M.......
output
WIN
input
.......A
........
........
........
........
........
SS......
M.......
output
LOSE
input
.......A
........
........
........
........
.S......
S.......
MS......
output
LOSE
分析:

搜索,BFS或是DFS,这里是用BFS写的。需要预先将每一秒所有雕像的位置都算清楚,以便与M判断是否相遇。

代码如下:

#include <cstdio>
#include <cstring>
struct point
{
    int x, y;
} que[3000000];
int sta_x[]= {1,1,1,-1,-1,-1,0,0,0};
int sta_y[]= {-1,0,1,-1,0,1,-1,1,0};
char a[10][10];
void Move()//移动雕像
{
    for(int i=7; i>=0; i--)
        for(int j=0; j<8; j++)
            if(a[i][j]=='S')
            {
                a[i+1][j]='S';
                a[i][j]='.';
            }
}
bool bfs()
{
    int font = 0, rear = 1, po=0;
    que[font].x = 7;
    que[font].y = 0;
    while(font<rear)
    {
        for(int i=0; i<9; i++)
            if(que[font].x+sta_x[i]>=0
             &&que[font].x+sta_x[i]<8
             &&que[font].y+sta_y[i]>=0
             &&que[font].y+sta_y[i]<8)
            {
                int xx = que[font].x+sta_x[i];
                int yy = que[font].y+sta_y[i];
                if(xx-1>=0 && a[xx-1][yy]=='S')
                    continue;
                if(a[xx][yy]=='S')
                    continue;
                if(xx==0 && yy==7)
                    return true;
                que[rear].x = xx;
                que[rear].y = yy;
                ++rear;
            }
        if(font>=po)// 每次步数加一时,所有石头往下掉一格
        {
            Move();
            po = rear;
        }
        ++font;
    }
    return false;
}
int main()
{
    while(scanf("%s", a[0]) != EOF)
    {
        for(int i=1; i<8; i++)
            scanf("%s", a[i]);
        if(bfs())
            puts("WIN");
        else
            puts("LOSE");
    }
    return 0;
}




AFSim 2.9实战指南:从入门到精通的中文教程 本文是AFSim 2.9的实战指南,提供从零开始的中文教程。内容涵盖仿真环境搭建、实体行为控制、脚本编写,到传感器、武器系统集成与复杂想定构建,最后讲解数据记录与结果分析方法,帮助用户快速掌握这一强大的军事仿真框架。 阅读详情

相关推荐

零基础小白Coze知识普及【新手必备资料!!】

AI智能体|扣子(Coze)工作流搭建【零基础小白Coze知识普及】 1、领取100+工作流源码!复制到扣子即可直接使用 2、AI认知+9节商业智能体拆解 3、500+各行业高质量提示词 4、超低价格使用即梦文生图图生视频和banana生图

Zhima0522的博客 3252

CodeForces128A - Statues 解题报告

CodeForces128A - Statues 解题报告

MYi_Qn的博客 521

信贷审批中的那些坑:从零开始搭建风控策略体系的5个关键步骤

本文深入探讨了信贷审批中的风控策略体系搭建,从数据陷阱识别、规则冲突诊断到反欺诈攻防,提供了5个关键步骤的实战指南。重点解析了如何通过特征工程、决策树优化和模型可解释性技术,构建动态平衡的风控体系,有效降低逾期风险并提升审批效率。

weixin_29253711的博客 414

Codeforces 128 A Statues【预处理+Bfs】

A. Statues time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output In this task Anna and Maria play a game with a very unplea

mengxiang000000 912

解决windows10下无法安装.net framework 3.5(包括.net2.0和3.0)

入域电脑,win10系统中安装 .net framework 3.5(包括.net2.0和3.0)

God_me_1的博客 4万+

2019年7月28日解决战网BLZBNTBNA00000005BLZBNTBNA00000006BLZBNTBTS0000005DBLZBNTBTS0000004A 007D0 008A4 00840

Blizzard—Battle.net—2019年7月28解决战网BLZBNTBNA00000005BLZBNTBNA00000006BLZBNTBTS0000005DBLZBNTBTS0000004A 007D0 008A4 008402019年7月28日再次更新写在前面■■■ 排查网路问题 ■■■■■■ 排查电脑自身问题 ■■■■尝试重置internet设置■网络的设置和防火墙规则■如果还是不...

MCGC高质人类协作会-MCG贴吧 3万+

CodeForces 128A Statues [基础DP]

棋盘模型,基础DP,把移动的棋子看做不动的之后再进行DP。

Asuna_acmer 558

Ego Planner规划算法(上)——Ego Planner流程介绍

本系列文章用于学习记录Ego-Planner规划算法的相关内容,本系列文章是在在Fast Planner规划算法系列文章的基础上,展开对Ego Planner的相关介绍,主要包括Ego Planner算法流程和程序框架两部分,主要学习资料是深蓝学院的移动机器人运动规划课程

慕羽★的博客 1万+

CodeForces 128A Statues 简单搜索

题目大意: 现在M从左下角走到右上角 时间 t 时刻可以向周围8个方向没有S的走或者保持原位, 到t + 1是所有S下落一位, 走的途中不能被S重合 问能否走到右上角 大致思路: 很简单的搜索了, dfs或bfs都可以, 没什么难度 我写的dfs... 代码如下: Result  :  Accepted     Memory  :  12 KB     Time  

Gatevin的专栏 1182

cuMotion 入门教程(一)面向机器人学的GPU加速运动生成技术

NVIDIA cuMotion是一款高性能机器人运动生成库,专注于机械操作任务,利用GPU加速技术提升性能。开发者预览版支持运动学/逆运动学、碰撞感知路径规划、轨迹优化等功能,兼容任意自由度机器人。该库提供C++和Python接口,支持从URDF/XRDF文件加载机器人模型,包含世界建模、碰撞检测等工具。教程详细介绍了安装配置、机器人描述加载、运动学计算、世界建模、逆运动学求解以及轨迹优化等核心功能。cuMotion整合了Lula和cuRobo库的技术优势,将成为Isaac ROS的核心组件,适用于工业机器

2506_90492529的博客 2202

UNet改进(54):当医学图像分割遇上频域学习与自监督

本文提出了一种改进U-Net的方法,通过频域增强模块和代理任务模块提升医学图像分割性能。频域增强模块在傅里叶空间对特征图进行可学习的频率调制,重点增强高频细节特征;代理任务模块通过图像重建约束编码器保留关键信息。两个模块协同工作,在仅增加5%参数量的情况下,形成空间域、频域和重建约束三条互补的信息路径。该方法特别适用于需要精细边缘分割的医学图像任务,预期能提升5%-10%的边缘分割精度,在小样本场景效果更显著。部署时可移除代理任务模块,不影响推理效率。未来可探索空间自适应频域调制和更丰富的代理任务设计。

2501_91516851的博客 227

Educational Codeforces Round 128 A-E题解

Educational Codeforces Round 128 A-E题 个人解题思路及代码记录

Cu_OH_2的博客 671

Ceph入门到精通-更换osd、扩容osd

【代码】Ceph入门到精通-更换osd、扩容osd。

隔壁老瓦的专栏 1548

Codeforces Round #128 (Div. 2) A. Two Problems

A. Two Problems time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output A boy Valera registered on site Codeforces

risker_2013的专栏 823

LinePhone3.2.7(android端最新版本) sip客户端

SIP客户端For android:LinePhone3.2.7(最新版本),官网地址:http://www.linphone.org/

RU DOS版、EFI版32bit/64bit BIOS常用工具

DOS版、EFI版的RU工具,可用来查看IO、MEM、PCI、SMBIOS等资源。亲测在EFI SHELL下可用。

【CF Educational Codeforces Round 128 Div. 2】A-C

A. Minimums and Maximums 题目 分析 给出一个数组的最大值最小值的个数范围,求出数组最少有多少个元素。最大最小值可以相同。 因为值可以相同,又要最小,所以如果他们范围是包含关系,直接可以使两个数相同,并输出他们最大的个数,如果不包含,只能分别占用个数,就是两个最小数的和。 代码 #include<bits/stdc++.h> #define pb push_back #define ll long long #define guanliu ios::sync

m0_56535442的博客 215

复分析 阿尔福斯(Ahlfors) 第三版答案 英文

答案分为十章,有部分习题没有答案,全英文复分析阿尔福斯(Ahlfors) 第三版答案

CF128A Statues 解题报告

CF128A Statues 解题报告

qq_61768466的博客 432

Probability and Statistics - 4th edition

Probability and Statistics - 4th edition

Gemma 4 系列模型发布:Google 开源模型的性能突破

北京时间4月3日凌晨,Google DeepMind正式发布了新一代开源大模型Gemma 4。这是自去年3月Gemma 3发布以来,Google在开源大模型领域的首次重大更新。

专注IT技术、AI实践与架构思考。 571

【codeforces 128C】Games with Rectangle

【题目链接】:http://codeforces.com/problemset/problem/128/C 【题意】 让你一层一层地在n*m的网格上画k个递进关系的长方形;(要求一个矩形是包含在另外一个矩形里面的); 问你有多少种方案; 【题解】 可以发现方案等同于在长和宽上各取2*k条直线的方案; 即C(n−1,2∗k)∗C(m−1,2∗k) ...

187

CodeForces 128C Games with Rectangle 组合数学

题目大意: 就是现在一个n*m的矩形当中塞K个小矩形(一层一层的) 个矩形都是包含关系且不相交 问有多少种不同方案 大致思路: 首先对于给出的n*m的矩形有(n - 1)*(m - 1)的顶点阵列 现在对于要选出的K个包含关系的矩形可以想到考虑每个K矩形的左上角和右下角, 一组左上和右下的点确定一个矩形 而对于K个左上角和K个左下角, 共2*K个点的横坐标都不相同, 纵坐标也是

Gatevin的专栏 869

Codeforces 1196A Three Piles of Candies

https://codeforces.com/contest/1196/problem/A 题解: /* *@Author: STZG *@Language: C++ */ #include <bits/stdc++.h> #include<iostream> #include<algorithm> #include<cstdlib> #i...

无限迭代中...... 551

Codeforces 760A-Petr and a calendar

Petr and a calendar time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Petr wants to make a calendar for curre

wang_128的博客 515

OpCore Simplify 完整上手指南:6 步自动生成可用的 OpenCore EFI

如果你正在装黑苹果(Hackintosh),被"该装哪些 kexts、该打哪些 ACPI 补丁、config.plist 里该填什么"这些问题卡住,这篇文章就是为你写的。OpCore Simplify 是一个在终端里运行的菜单化工具,你把硬件信息交给它,它就能自动完成兼容性检查、补丁与 kexts 匹配、config.plist 生成和 EFI 打包,把原本要手动逐行配置的流程变成 6 步菜单操作

gitblog_00487的博客 758

【题目记录】——Educational Codeforces Round 128 (Rated for Div. 2)

文章目录A Minimums and MaximumsB RobotsC Binary String A Minimums and Maximums 题目大意:一个漂亮的数组,需要满足以下条件 最小值的数量大于l1,小于r1 最大值的数量大于l2,小于r2 给出l1,r1,l2,r2找出最小的可能的元素的数量的数组 思路:如果两个区间有交叉的话,那就是交叉区间的左端点 如果没有交叉的话就是l1+l2 #include<bits/stdc++.h> using namespace std; int

气派飞鹰的博客 308

Codeforces Round 1013(Div.3)(A-F)

题意:从a1​开始,抽到哪能使这些数字组成日期思路:拿个map记录下数量就行。

johnstones55的博客 783

4GB显存也能跑7B模型?Olmo-3-7B-Instruct-unsloth-bnb-4bit的4-bit量化原理详解

🤖 **Olmo-3-7B-Instruct-unsloth-bnb-4bit** 是开源大语言模型 Olmo-3-7B-Instruct 的 **4-bit 量化** 版本,由 Unsloth Dynamic 2.0 技术压缩而成。量化后,7B 模型的权重从约 14 GB 压缩到仅 5.2 GB 左右,让中端甚至低显存的显卡也有机会在本地跑起 7B 模型。这篇文章带你用大白话搞懂 bnb-4b

gitblog_02049的博客 453
上一篇: HDU 4190 - Distributing Ballot Boxes
下一篇: UVa 11624 - Fire!
GooMaple
博客等级 码龄14年 79粉丝 197原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值