Secret Poems HihoCoder - 1632(模拟)

题目名称:组个最小数时间限制:1000ms内存限制:256MB提交通过率:43% 例如:给定三个 1,三个 0,三个 5,一个 8,我们得到的最小的数就是 1000115558。给定数字 0...9 各若干个,总共十个数字。你可以以任意顺序排列这些数字,但必须全部使用。在一行中给出 10 个 0...9 之间的整数,每个数字间用空格隔开。经过测试,两个方法的时间和空间基本相同,根据情况自行选择吧,886~目标是使得最后得到的数尽可能小(注意 0 不能做首位)。现给定数字,请编写程序输出能够组成的最小的数。给定数字中至少有 1 个非 0 的数字。在一行中输出能够组成的最小的数。 阅读详情

Secret Poems HihoCoder - 1632

The Yongzheng Emperor (13 December 1678 – 8 October 1735), was the fifth emperor of the Qing dynasty of China. He was a very hard-working ruler. He cracked down on corruption and his reign was known for being despotic, efficient, and vigorous.

Yongzheng couldn’t tolerate people saying bad words about Qing or him. So he started a movement called “words prison”. “Words prison” means literary inquisition. In the famous Zhuang Tinglong Case, more than 70 people were executed in three years because of the publication of an unauthorized history of the Ming dynasty.

In short, people under Yongzheng’s reign should be very careful if they wanted to write something. So some poets wrote poems in a very odd way that only people in their friends circle could read. This kind of poems were called secret poems.

A secret poem is a N×N matrix of characters which looks like random and meaning nothing. But if you read the characters in a certain order, you will understand it. The order is shown in figure 1 below:

[f.png]

            figure 1                                                           figure 2

Following the order indicated by arrows, you can get “THISISAVERYGOODPOEMITHINK”, and that can mean something.

But after some time, poets found out that some Yongzheng’s secret agent called “Mr. blood dripping” could read this kind of poems too. That was dangerous. So they introduced a new order of writing poems as shown in figure 2. And they wanted to convert the old poems written in old order as figure1 into the ones in new order. Please help them.

Input

There are no more than 10 test cases.

For each test case:

The first line is an integer N( 1 <= N <= 100), indicating that a poem is a N×N matrix which consist of capital letters.

Then N lines follow, each line is an N letters string. These N lines represent a poem in old order.

Output

For each test case, convert the poem in old order into a poem in new order.

Sample Input

5
THSAD 
IIVOP 
SEOOH 
RGETI 
YMINK
2
AB
CD
4
ABCD
EFGH
IJKL
MNOP

Sample Output

THISI
POEMS
DNKIA
OIHTV
OGYRE
AB
DC
ABEI
KHLF
NPOC
MJGD
题意:

将题目给的第一种形式的矩阵转变成第二种输出

分析:

费劲的模拟

code:

#include <bits/stdc++.h>
using namespace std;
int n;
char G[110][110];
char ans[110][110];
char ans2[110][110];
int main(){
    while(~scanf("%d",&n)){
        for(int i = 0; i < n; i++){
            scanf("%s",G[i]);
        }
        int x = 0,y = 0;
        int row = 0,col = 0;
        int flag = 0;
        int flag2 = 0;
        while(1){
            ans[row][col] = G[x][y];
            if((x == 0 || y == 0 || x == n-1 || y == n-1) && flag2 == 0){
                if(x == n-1 && y == n-1) break;
                if(x == 0 && y == 0){
                    y++;
                    flag = 1;
                    flag2 = 1;
                }
                else if(x == 0 || y == n-1){
                    if(x == 0 && y == n-1) x++;
                    else if(x == 0) y++;
                    else if(y == n-1) x++;
                    flag = 1;
                    flag2 = 1;
                }
                else if(x == n-1 || y == 0){
                    if(x == n-1) y++;
                    else if(y == 0) x++;
                    flag = 2;
                    flag2 = 1;
                }
            }
            else{
                flag2 = 0;
                if(flag == 1){
                    x++;
                    y--;
                }
                else if(flag == 2){
                    x--;
                    y++;
                }
            }
            col++;
            if(col == n){
                col = 0;
                row++;
            }
            if(row == n) break;
        }
        row = 0;
        col = 0;
        flag = 0;
        memset(ans2,'#',sizeof(ans2));
        for(int i = 0; i < n; i++){
            for(int j = 0; j < n; j++){
                ans2[row][col] = ans[i][j];
                if(flag == 0){
                    col++;
                    if(col == n-1 || ans2[row][col+1] != '#') flag = 1;
                }
                else if(flag == 1){
                    row++;
                    if(row == n-1 || ans2[row+1][col] != '#') flag = 2;
                }
                else if(flag == 2){
                    col--;
                    if(col == 0 || ans2[row][col-1] != '#') flag = 3;
                }
                else if(flag == 3){
                    row--;
                    if(ans2[row-1][col] != '#') flag = 0;
                }
            }
        }
        for(int i = 0; i < n; i++){
            for(int j = 0; j < n; j++){
                putchar(ans2[i][j]);
            }
            putchar('\n');
        }
    }
    return 0;
}
matlab 求解多项式的根 四种方法 matlab 求解多项式的根 四种方法 方法一 %多项式求根函数roots p=[1,-3,1];%建立多项式系数向量p x=roots(p)%求多项式的根 x=-5:0.1:5;%步长为0.1 y1=x.*x-3*x+1;%构建一个函数 y2=zeros(size(x));%产生一个与x同大小的零向量 plot(x,y1,x,y2); 方法二 %利用函数fzero f=@(x)x*x-3*x+1; x1=fzero(f,0.5) x2=fzero(f,2.5) 方法三 %利用f 阅读详情

相关推荐

VGG16

VGG16学习笔记

一去不复返的通信er 1177

15北京网络赛 E题

题目描述:题目5 : Border Length时间限制:1000ms单点时限:1000ms内存限制:256MB描述Garlic-Counting Chicken is a special species living around the Lake of Peking University.A Garlic-Counting Chicken always flies out from home i

ruclion的专栏 482

VL53L1X移植到STM32实战记录,使用软件IIC(附源代码)

序言 VL53L1X是一个很小又很优秀的测距传感器,它相比于上一代VL53L0X有着不小的提升,这次毕业设计打算将这个传感器用起来,就来移植了一下,遇到的坑怎么说还是有一些,故在此分享给大家。 开发环境 IDE:Keil V5 STM32CubeMX ,使用HAL库 具体操作 获取官方库并进行移植 这一步是移植的基础,首先从官方把API库下下来,并添加到IDE中: 适配硬件 这里由于不同的硬件平...

wmdscjhdpy的博客 1万+

Secret Poems(字符串处理)

Secret Poems The Yongzheng Emperor (13 December 1678 – 8 October 1735), was the fifth emperor of the Qing dynasty of China. He was a very hard-working ruler. He cracked down on corruption and his r

mjj1024的博客 1083

LabView实战:精准实现float到十六进制的转换与高低位拆分

本文详细讲解了在LabVIEW中实现单精度浮点数(float)到十六进制字符串转换,并进行高低16位拆分的实战方法。针对工业通信中设备协议要求,核心使用强制类型转换(Type Cast)获取内存原始数据,避免数值转换错误,并提供了完整的VI构建步骤、交叉验证技巧及常见踩坑经验(如字节序、字符串格式),确保数据通信的准确性。

assembly8low的博客 1765

从SolidWorks到Simscape:URDF导出模型错位的5个常见原因及修复方法

本文深入分析了从SolidWorks导出URDF模型到Simscape时出现模型错位的5个常见原因,包括坐标系定义、RPY角陷阱、轴方向统一、质量属性导出和层次结构错乱,并提供了详细的修复方法和实战技巧,帮助工程师高效解决模型错位问题。

weixin_30664051的博客 442

ACM-ICPC北京赛区2017网络同步赛 (题目6 : Secret Poems)

#1632 : Secret Poems 时间限制:1000ms 单点时限:1000ms 内存限制:256MB 描述 The Yongzheng Emperor (13 December 1678 – 8 October 1735), was the fifth emperor of the Qing dynasty of China. He wa

yan 808

Python 爬虫实战:Boss直聘 Python 岗位招聘数据爬取

本文介绍了一个Python爬虫项目,用于抓取Boss直聘平台的Python岗位招聘数据并进行可视化分析。项目采用requests库发送POST请求,通过抓包分析获取JSON接口,绕过HTML解析直接获取结构化数据。主要内容包括: 接口分析:找到关键POST接口,解析请求头和JSON参数格式 环境准备:安装requests/pandas/matplotlib/pyecharts等依赖库 核心实现: 手动获取登录Cookie 构建请求头和城市代码映射 实现分页抓取职位列表数据 项目特色在于直接解析JSON接口而

u014481728的博客 296

HihoCoder - 1632 Secret Poems (2017ICPC北京站 模拟)

#1632 : Secret Poems 时间限制:1000ms 单点时限:1000ms 内存限制:256MB 描述 The Yongzheng Emperor (13 December 1678 – 8 October 1735), was the fifth emperor of the Qing dynasty of China. He wa

LP_Cong 850

《自然语言处理实战入门》文本分类 ---- 使用词向量与SVM 进行文本分类

文本分类用电脑对文本集(或其他实体或物件)按照一定的分类体系或标准进行自动分类标记。 它根据一个已经被标注的训练文档集合, 找到文档特征和文档类别之间的关系模型, 然后利用这种学习得到的关系模型对 新的文档进行类别判断 。文本分类从基于知识的方法逐渐转变为基于统计 和机器学习的方法。

shiter编写程序的艺术 2388

STC单片机使用FatFs文件系统读取SD卡指定文件内容

STC单片机使用FatFs文件系统读取SD卡指定文件内容

perseverance51博客 2744

HihoCoder - 1632 Secret Poems(模拟)

The Yongzheng Emperor (13 December 1678 – 8 October 1735), was the fifth emperor of the Qing dynasty of China. He was a very hard-working ruler. He cracked down on corruption and his reign was known f...

birdmanqin的博客 205

【天气雷达】双偏振产品-差分反射率ZDR详解

双偏振产品-差分反射率ZDR详解。

珞瑜的博客 5407

hihoCoder-1632-Secret Poems(大模拟)

时间限制:1000ms 单点时限:1000ms 内存限制:256MB 描述 The Yongzheng Emperor (13 December 1678 – 8 October 1735), was the fifth emperor of the Qing dynasty of China. He was a very hard-working ruler. He

wust_cyh 414

ET2012新版免狗免安装绿色软件

ET2012新版免狗免安祖昂绿色软件。,新界面,新视觉,

迈瑞BS系列全自动生化分析仪LIS协议接口手册(内含HL7和ASTM)

迈瑞BS系列全自动生化分析仪LIS协议接口手册,内含HL7和ASTM)

Secret Poems HihoCoder - 1632(一道模拟题)

Problem Description The Yongzheng Emperor (131313 December 1678–81678 – 81678–8 October 173517351735), was the fifth emperor of the Qing dynasty of China. He was a very hard-working ruler. He cracked ...

我の名字 283

数学建模模型总结

这是本人在两年内准备参加数学建模竞赛搜集到的模型资料,已经经过了本人的筛选和整理,希望能够对准备参加数学建模竞赛的学弟学妹们提供一些帮助!

【恐怖的数组模拟】Secret Poems - HihoCoder - 1632

Secret Poems - HihoCoder - 1632   图一                图二 Following the order indicated by arrows, you can get “THISISAVERYGOODPOEMITHINK”, and that can mean something.But after some time, poets fou...

weixin_30907523的博客 184

WINCC7.3破解文件

WINCC7.3硬件够破解文件,有需要的下载!WINCC7.3硬件够破解文件,有需要的下载!

HihoCoder 1632 Secret Poems(模拟)

https://hihocoder.com/problemset/problem/1632   将左边的图按顺序输出成右边的图 大致思路是左右2个指针去填充。 所以要做到知道x,y就知道箭头方向。那么就是看规律了。 对于左边这张图,我们可以看出→和↓都在四周出现,之后通过x与y的和的奇偶来判↗和↙5 对于右图螺旋线,我们和划一个叉叉 ,把它变成四部分,然后就可以看出规律了。。。类似...

三水的鱼塘♂ 349

HihoCoder - 1632—Secret Poems (模拟&&字符串)

The Yongzheng Emperor (13 December 1678 – 8 October 1735), was the fifth emperor of the Qing dynasty of China. He was a very hard-working ruler. He cracked down on corruption and his reign was known ...

刘二狗的博客 427

HihoCoder 1632 Secret Poems 北京2017 ICPC

北京这题真的是 模拟到爆炸 #include<bits/stdc++.h> #define ll long long using namespace std; const int maxn = 1e3 + 5; char mp[maxn][maxn]; char id[maxn * maxn]; char ans[maxn][maxn]; int n, m; bool vis[ma...

蒟蒻的最后的倔强 203

hihocoder #1632 : Secret Poems

#include <bits/stdc++.h> using namespace std; const int maxn = 105; char str[maxn][maxn],ans[maxn][maxn],vis[maxn][maxn],vis2[maxn][maxn]; int dir1[4][2] = { {-1,1},{ 1,-1 },{0,1},{1,0} }; int ...

ehdhg13455的博客 143

hihocoder 1632 Secret Poems

题目链接:Secret Poems题目大意:给你一个某种路径形成的字符串,还原后用另一种方法表示题目思路:按题意模拟就好了,还原的时候分一下上下三角,然后上下三件移动的方向是成循环的,下半角需要分一下奇偶以确定初始方向 #include <map> #include <set> #include <cmath> #include <vector> #include <cstdio> #include

Nemaleswang的博客 408

F - Secret Poems HihoCoder - 1632 -图形读取+打印

F - Secret Poems  HihoCoder - 1632  题意:按照第一种格式读入,按照第二种格式输出 #include&lt;bits/stdc++.h&gt; using namespace std; #define maxn 111 int ans,n,m,t,x; char str[maxn][maxn]; string s; void dfs(int x...

BePosit的博客 252

HihoCoder - 1632 Secret Poems

The Yongzheng Emperor (13 December 1678 – 8 October 1735), was the fifth emperor of the Qing dynasty of China. He was a very hard-working ruler. He cracked down on corruption and his reign was known f

zitian246的博客 248

Hihocoder 1632 : Secret Poems 思维|技巧

题意定义一个矩阵 他有n*n大小 然后给出他的真实信息的走法 让我们变换走法 再次把真实信息填入矩阵中 n<=100分析可以发现原文的读取方式无非就是如此 (0,1)向左 (1,-1)左下 (1,0)向下 (-1,1)右上 1边界检查 (1,0)向下 (1,-1)左下 (0,1)向左 (-1,1)右上 2退出检查 观察发现其中下和左移动都是1步

qq_33859479的博客 405

HihoCoder - 1632 Secret Poems(规律题)

【题目】 Secret Poems 【题意】 给定n*n的矩阵,按左边的顺序再以右边的顺序输出。(讲道理我没看题哈哈哈,典型样例推题意) 【思路】 规律显而易见,就是实现起来有点麻烦。 change1表示图二的位置变化,change2表示图一,因为我一开始把图一的想简单了先搞的图二。好像没什么好讲的... 上代码。 【代码】 const int dx[]={1,0,-1,0...

菜鸡成长史 221

hihoCoder 1632 secret poem (2017北京赛区)

题意:给你两张图,首先按第一张图的指定顺序读取字母,然后再按第二张图指定的顺序填入数组。最后输出此数组。input:5 THSAD IIVOP SEOOH RGETI YMINKoutput:THISI POEMS DNKIA OIHTV OGYRE左边的图其实就类似于cantor表的顺序,右边的图类似于蛇形矩阵。 没有什么技巧,就是暴力模拟。 定义两个(x1,y1)

Link_Ray的博客 463
上一篇: Cats and Fish HihoCoder - 1631(思维模拟)
下一篇: Pangu and Stones HihoCoder - 1636 (区间dp)
Guuuuuu老师儿
博客等级 码龄9年 259粉丝 718原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值