题目意思:
就是要对角线扫描一个矩阵,
原题也很啰嗦:
Ural doctors worry about the health of their youth very much. Special investigations showed that a lot of clever students instead of playing football, skating or bicycling had participated in something
like Programming Olympiads. Moreover, they call it sports programming! To sit near the monitor and think during 5 hours a day – is it a sport? To do it two times per year during the contests – it is more or less normal, but during the preparations to the nearest
contest they spend several hours a week sitting at their computers! It would be possible to understand if they were some blockheads and dunces, but they are ones of the best students all over the world!
To save students from the harmful habit to sit at the computer for hours, Ural doctors has invented a fundamentally new monitor with diagonal trace of a beam in its electron-beam tube. Soon the winners
of Ural Programming Championship would be awarded with such monitors. In the specially designed square monitor the electronic beam would scan the screen not horizontally but diagonally. The difference of the lengths of different diagonals causes such effects
as non-uniform brightness, flashing and non-linear distortions. The terrible properties of such monitors would break of the habit of looking at the monitor for hours. There is a little problem: the majority of computer video cards generates the normal “rectangle”
signal for monitor. So it is necessary to develop special adapter-program, which should transform the usual “rectangle” signal to the signal necessary for this kind of monitors. Program should be fast and reliable. That’s why the development of this program
is entrusted to the participants of the Ural Championship for Sports Programming.
Input
The first input line contains the single integer N (1 ≤ N ≤ 100) – the number of pixels on the side of new square monitor. It is followed by N lines, each containing N positive integers not exceeding
100 divided by spaces. It is the image outputting by the usual video card (as you can see the color depth of new monitor is not so large – anyway usual programmer does not need more than 100 colors).
Output
You are to write the program that outputs the sequence for input into the new monitor. Pixels are numbered from the upper-left corner of the screen diagonally from left ot right and bottom-up. There
is no need to explain details – look at the sample and you'll understand everything.
Sample
input
output
4
1 3 6 10
2 5 9 13
4 8 12 15
7 11 14 16
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
|
看到最后的例子就知道什么意思了。
这样的题目好处就是可以锻炼计算下标的能力,这个在很多难题中都是很重要的。
要一次性作对还真不容易:
void SomeWordsaboutSport()
{
int n = 0;
cin>>n;
vector<vector<int> > squ(n, vector<int>(n));
for (int i = 0; i < n; i++)
{
for (int j = 0; j < n; j++)
{
cin>>squ[i][j];
}
}
for (int i = 0; i < n; i++)
{
for (int j = i, k = 0; j >= 0; j--, k++)
{
cout<<squ[j][k]<<' ';
}
}
for (int i = 1; i < n; i++)
{
for (int j = n - 1, k = i; k < n; j--, k++)
{
cout<<squ[j][k]<<' ';
}
}
}
分享到:
相关推荐
acm.timus.ru最全代码
Timus ... Problems code. (Mainly Java implementation) Chinese 刷题代码,主要是java实现,可能会有其他语言代码 代码来自LeetCode / NowCoder / timus 等 site url LeetCode NowCoder Timus LeetCode-cn
acm.timus.ru解决方案 这些是我对ACM.TIMUS.RU问题的解决方案
timus.ru_solutions 使用的语言:Python 使用的Python版本:3.9 我可以用Python语言解决的一些问题在“ python”目录中。 有些解决方案可以在Java中运行,但确切的解决方案/算法在Python中不起作用! 不知道为什么我...
acm.timus.ru 1709 problem
timus.ru_solutions_python 使用的python:3.9 我可以用Python语言解决的一些问题在python目录中。 有些解决方案可以在Java中运行,但确切的解决方案/算法在Python中不起作用! 我不知道为什么
资源分类:Python库 所属语言:Python 资源全名:timus-sender-0.1.1.post1.tar.gz 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059
Timus上习题解答与代码参考,这一部分对应于Timus上的Beginner部分的习题
timus:Timus在线法官问题
将图表添加到Timus Online Judge配置文件 该扩展程序将已解决问题的数量图表添加到Timus Online Judge的个人资料和比较器中。 功能:*概要文件和比较中已解决问题计数的图表*向图表中添加更多用户,删除它们,自定义...
timus OJ 1197 lonesome kinght
Timus图表 将图表添加到Timus Online Judge个人资料中 特征 概要文件中和比较期间已解决问题的计数图表 向图表添加更多用户,删除它们,自定义图例颜色 缓存配置文件数据 隐藏图表 (可选)突出显示最近两个月内接受...
蒂莫斯 该文件夹包含用Python编写的文件(主要是Python2.7,有些是Python3.4)我通过这些文件在timus上通过了相应的测试。
http://acm.timus.ru 俄罗斯乌拉尔大学在线题库 SGU http://acm.sgu.ru/ 俄罗斯圣萨拉托夫州大学在线题库 ELJ http://acm.mipt.ru/judge/bin/problems.pl?lang=en file:///M|/acm/ACM大量习题题库及建议培养计划.txt...
timus-online-judge Timus Online Judge 是俄罗斯最大的带有自动评判系统的编程问题档案。 问题主要是从在乌拉尔联邦大学、乌拉尔锦标赛、乌拉尔 ACM ICPC 次区域比赛和彼得罗扎沃茨克训练营举办的比赛中收集的。 ...
语言:English将图表添加到Timus Online Judge个人资料中该扩展程序将已解决问题的数量图表添加到Timus Online Judge的个人资料和比较器中。功能:*概要文件和比较中已解决问题计数的图表*向图表中添加更多用户,删除...
http://acm.timus.ru/problem.aspx?space=1&num=1362 一道树形动态规划的题目解答,ural1362
Pascal acm_timus_ural_1148.pas
Pascal acm_timus_ural_1099.pas
1. 介绍了一些著名的综合性OJ网站,如UVa、POJ、Timus、SGU等,题目数量大、种类全面。 2. 推荐了针对新手入门的OJ网站,如HDU、ZJU等,收集了不少水题,适合新手起步训练。 3. 介绍了一些以赛事见长的OJ网站,如...