Ural 1313 - Some Words about Sport

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

inputoutput
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
Problem Author: Idea - Stanislav Vasilyev, prepared by Stanislav Vasilyev and Alexander Klepinin Problem Source: VIII Collegiate Students Urals Programming Contest. Yekaterinburg, March 11-16, 2004
复制代码
// Ural Problem 1313. Some Words about Sport
// Verdict: Accepted  
// Submission Date: 20:50:20 14 Jan 2014
// Run Time: 0.031s
//  
// 版权所有(C)acutus   (mail: acutus@126.com) 
// 博客地址:http://www.cnblogs.com/acutus/
// [解题方法]  
// 简单题,直接找矩阵规律即可

#include<stdio.h>

void solve()
{
    int i, t, j, N, a[100][100], M;
    scanf("%d",&N);
    for(i = 0; i < N; i++) {
        for(j = 0; j < N; j++) {
            scanf("%d", &a[i][j]);
        }
    }
    t = 1;
    M = 2 * N - 2;
    printf("%d", a[0][0]);
    while(t <= M) {
        if(t <= N - 1) {
            for(j = 0; j <= t; j++) {
                printf(" %d",a[t - j][j]);
            }
        } else {
            for(j = t - (N - 1); j <= N - 1; j++) {
                printf(" %d", a[t - j][j]);
            }
        }
        t++;
    }
    printf("\n");
}

int main()
{
    solve();
    return 0;
}
复制代码

 

posted @   acutus  阅读(214)  评论(0编辑  收藏  举报
编辑推荐:
· 智能桌面机器人:用.NET IoT库控制舵机并多方法播放表情
· Linux glibc自带哈希表的用例及性能测试
· 深入理解 Mybatis 分库分表执行原理
· 如何打造一个高并发系统?
· .NET Core GC压缩(compact_phase)底层原理浅谈
阅读排行:
· 新年开篇:在本地部署DeepSeek大模型实现联网增强的AI应用
· DeepSeek火爆全网,官网宕机?本地部署一个随便玩「LLM探索」
· Janus Pro:DeepSeek 开源革新,多模态 AI 的未来
· 上周热点回顾(1.20-1.26)
· 【译】.NET 升级助手现在支持升级到集中式包管理
TOP
点击右上角即可分享
微信分享提示