結果

問題 No.401 数字の渦巻き
ユーザー mbanmban
提出日時 2016-09-26 20:23:24
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 60 ms / 2,000 ms
コード長 2,193 bytes
コンパイル時間 2,312 ms
コンパイル使用メモリ 104,116 KB
実行使用メモリ 22,852 KB
最終ジャッジ日時 2023-08-11 21:18:41
合計ジャッジ時間 5,556 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 59 ms
22,848 KB
testcase_01 AC 59 ms
20,728 KB
testcase_02 AC 58 ms
20,664 KB
testcase_03 AC 59 ms
20,848 KB
testcase_04 AC 58 ms
20,664 KB
testcase_05 AC 59 ms
20,680 KB
testcase_06 AC 60 ms
20,788 KB
testcase_07 AC 59 ms
20,824 KB
testcase_08 AC 58 ms
20,804 KB
testcase_09 AC 59 ms
22,828 KB
testcase_10 AC 59 ms
20,812 KB
testcase_11 AC 59 ms
22,680 KB
testcase_12 AC 60 ms
20,664 KB
testcase_13 AC 60 ms
22,808 KB
testcase_14 AC 60 ms
22,776 KB
testcase_15 AC 59 ms
20,748 KB
testcase_16 AC 60 ms
20,652 KB
testcase_17 AC 59 ms
18,724 KB
testcase_18 AC 59 ms
20,672 KB
testcase_19 AC 60 ms
20,768 KB
testcase_20 AC 60 ms
22,852 KB
testcase_21 AC 60 ms
22,772 KB
testcase_22 AC 59 ms
20,760 KB
testcase_23 AC 60 ms
20,784 KB
testcase_24 AC 60 ms
20,852 KB
testcase_25 AC 60 ms
20,736 KB
testcase_26 AC 59 ms
20,852 KB
testcase_27 AC 60 ms
20,684 KB
testcase_28 AC 60 ms
22,816 KB
testcase_29 AC 60 ms
20,868 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;

class Magatro {
   static long N = long.Parse(Console.ReadLine());
    static void Main() {
        int[,] masu = new int[N, N];
        //左=0
        int muki = 0;
        int x = 0, y = 0;
        for(int i = 0; i < N * N; i++) {
            masu[x, y] = i + 1;
            switch (muki) {
                case 0:
                    if (x + 1 < N ) {
                        if (masu[x + 1, y] == 0) {
                            x++;
                            break;
                        }
                     
                    }
                    muki++;
                    y++;
                    
                    break;
                case 1:
                    if (y + 1 < N ) {
                        if (masu[x, y + 1] == 0) {
                            y++;
                            break;
                        }
                    }
                    muki++;
                    x--;
                    break;
                case 2:
                    if (x - 1 >= 0 ) {
                        if (masu[x - 1, y] == 0) {
                            x--;
                            break;
                        }
                    }
                    muki++;
                    y--;
                    break;
                case 3:
                    if (y - 1 >= 0) {
                        if (masu[x , y-1] == 0) {
                            y--;
                            break;
                        }
                    }
                    muki=0;
                    x++;
                    break;
            }
        }
        for(int i = 0; i < N; i++) {
            string s = "";
            for(int j = 0; j < N; j++) {                
                if (j == N - 1) {
                    s+= string.Format("{0:D3}", masu[j, i]);
                }
                else {
                    s += string.Format("{0:D3}", masu[j, i])+" ";
                }
            }
            Console.WriteLine(s);
        }
    }

}
0