結果

問題 No.466 ジオラマ
ユーザー 14番14番
提出日時 2016-12-16 02:22:09
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 4,378 bytes
コンパイル時間 3,656 ms
コンパイル使用メモリ 108,920 KB
実行使用メモリ 31,736 KB
最終ジャッジ日時 2023-08-20 08:44:18
合計ジャッジ時間 14,468 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 64 ms
23,816 KB
testcase_01 AC 62 ms
23,792 KB
testcase_02 AC 65 ms
23,812 KB
testcase_03 AC 64 ms
21,880 KB
testcase_04 AC 64 ms
23,868 KB
testcase_05 AC 62 ms
21,888 KB
testcase_06 AC 75 ms
27,492 KB
testcase_07 AC 70 ms
23,872 KB
testcase_08 AC 76 ms
28,172 KB
testcase_09 AC 68 ms
23,988 KB
testcase_10 AC 73 ms
27,216 KB
testcase_11 AC 71 ms
26,204 KB
testcase_12 AC 74 ms
31,736 KB
testcase_13 AC 69 ms
23,808 KB
testcase_14 AC 70 ms
23,816 KB
testcase_15 AC 69 ms
21,920 KB
testcase_16 AC 64 ms
21,756 KB
testcase_17 AC 67 ms
23,912 KB
testcase_18 AC 69 ms
25,796 KB
testcase_19 AC 69 ms
23,884 KB
testcase_20 AC 69 ms
23,892 KB
testcase_21 AC 67 ms
23,960 KB
testcase_22 AC 71 ms
27,496 KB
testcase_23 AC 68 ms
25,864 KB
testcase_24 AC 73 ms
27,592 KB
testcase_25 AC 76 ms
27,660 KB
testcase_26 AC 71 ms
23,840 KB
testcase_27 AC 75 ms
25,796 KB
testcase_28 AC 73 ms
29,248 KB
testcase_29 AC 76 ms
28,040 KB
testcase_30 AC 69 ms
24,068 KB
testcase_31 AC 69 ms
24,060 KB
testcase_32 AC 69 ms
26,052 KB
testcase_33 AC 70 ms
26,064 KB
testcase_34 AC 73 ms
29,188 KB
testcase_35 AC 69 ms
24,040 KB
testcase_36 AC 67 ms
21,932 KB
testcase_37 AC 61 ms
21,756 KB
testcase_38 AC 68 ms
23,912 KB
testcase_39 AC 60 ms
21,888 KB
testcase_40 AC 70 ms
26,092 KB
testcase_41 AC 62 ms
21,880 KB
testcase_42 AC 69 ms
23,984 KB
testcase_43 AC 63 ms
21,888 KB
testcase_44 AC 68 ms
23,920 KB
testcase_45 AC 63 ms
21,880 KB
testcase_46 AC 68 ms
21,996 KB
testcase_47 AC 61 ms
21,864 KB
testcase_48 AC 72 ms
27,160 KB
testcase_49 AC 62 ms
23,924 KB
testcase_50 AC 68 ms
24,112 KB
testcase_51 AC 62 ms
21,876 KB
testcase_52 AC 69 ms
26,088 KB
testcase_53 AC 62 ms
23,752 KB
testcase_54 AC 69 ms
26,096 KB
testcase_55 AC 61 ms
25,924 KB
testcase_56 AC 62 ms
19,724 KB
testcase_57 AC 62 ms
21,900 KB
testcase_58 AC 63 ms
23,820 KB
testcase_59 AC 61 ms
21,688 KB
testcase_60 AC 62 ms
21,972 KB
testcase_61 AC 61 ms
21,880 KB
testcase_62 AC 62 ms
19,804 KB
testcase_63 AC 61 ms
19,892 KB
testcase_64 AC 62 ms
21,844 KB
testcase_65 AC 63 ms
23,948 KB
testcase_66 AC 74 ms
27,308 KB
testcase_67 AC 61 ms
21,828 KB
testcase_68 AC 69 ms
21,840 KB
testcase_69 AC 62 ms
21,872 KB
testcase_70 AC 68 ms
25,876 KB
testcase_71 AC 62 ms
21,864 KB
testcase_72 AC 67 ms
23,856 KB
testcase_73 AC 61 ms
21,772 KB
testcase_74 AC 69 ms
21,892 KB
testcase_75 AC 63 ms
21,968 KB
testcase_76 AC 62 ms
23,744 KB
testcase_77 AC 61 ms
21,848 KB
testcase_78 AC 61 ms
23,824 KB
testcase_79 AC 61 ms
23,924 KB
testcase_80 AC 62 ms
21,916 KB
testcase_81 AC 62 ms
21,788 KB
testcase_82 AC 62 ms
23,780 KB
testcase_83 WA -
testcase_84 AC 66 ms
23,968 KB
testcase_85 AC 81 ms
31,252 KB
testcase_86 AC 62 ms
21,796 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.Linq;
using System.Collections.Generic;
using System.Text;

public class Program
{
    public void Proc() {
        Reader.IsDebug = false;
        int[] inpt = Reader.ReadLine().Split(' ').Select(c=>int.Parse(c)).ToArray();

        int a = inpt[0];
        int b = inpt[1];
        int aAndB = inpt[2];
        int roadCount = inpt[3];

        if(aAndB > 0 && a+b-aAndB-1>roadCount) {
            Console.WriteLine(-1);
            return;
        }
        if(aAndB == 0 && a+b-2>roadCount) {
            Console.WriteLine(-1);
            return;
        }
        if(aAndB > 0 && (a<=1 || b<=1)) {
            Console.WriteLine(-1);
            return;
        }

        TreeNode t0 = new TreeNode(0);
        TreeNode t1 = new TreeNode(1);

        if(aAndB == a && b != aAndB) {
            t1.Add(t0);
            int idx = 2;
            if(a>1) {
                t0.AddRange(idx, idx+a-2);
            }
            idx = idx+a-1;
            if(b-aAndB>1) {
                t1.AddRange(idx, idx+(b-aAndB)-2);
            }
        } else if(aAndB == b && a != aAndB) {
            t0.Add(t1);
            int idx = 2;
            if(b>1) {
                t1.AddRange(idx, idx+b-2);
            }
            idx = idx+b-1;
            if(a-aAndB>1) {
                t0.AddRange(idx, idx+(a-aAndB)-2);
            }
       } else if(a == b && a == aAndB) {
           if(roadCount < a) {
               Console.WriteLine(-1);
               return;
           }
           StringBuilder tmp = new StringBuilder();
           tmp.AppendLine(a + " " + b);
           tmp.AppendLine("1 0");
           tmp.AppendLine("0 1");
           for(int i=2; i<a; i++) {
               tmp.AppendLine("0 " + i);
           }
           Console.Write(tmp.ToString());
           return;
        } else {
            TreeNode t2 = null;
            int idx = 2;
            if(aAndB > 0) {
                t2 = new TreeNode(2);
                idx++;
                if(aAndB >1) {
                    t2.AddRange(idx, idx+aAndB-2);
                    idx=idx+aAndB-1;
                }
                t0.Add(t2);
                t1.Add(t2);
            }
            if(a-aAndB>1) {
                t0.AddRange(idx, idx+(a-aAndB)-2);
                idx = idx+(a-aAndB)-1;
            }
            if(b-aAndB>1) {
                t1.AddRange(idx, idx+(b-aAndB)-2);
            }
        }

        StringBuilder ans = new StringBuilder();
        ans.Append(t0.Print());
        ans.Append(t1.Print());
        int mura = a+b-aAndB;
        int road = mura-1;
        if(aAndB == 0) {
            road--;
        }
        Console.WriteLine(mura + " " + road);
        Console.Write(ans.ToString());
    }

    public class TreeNode {
        public int Id;

        public List<TreeNode> Items = new List<TreeNode>();

        public TreeNode(int id) {
            this.Id = id;
        }
        public void Add(TreeNode cld) {
            this.Items.Add(cld);
        }

        private bool IsPrinted = false;
        public string Print() {
            if(this.IsPrinted) {
                return string.Empty;
            }
            this.IsPrinted = true;
            StringBuilder ret = new StringBuilder();
            this.Items.ForEach(a=>{
                    ret.AppendLine(this.Id + " " + a.Id);
                    ret.Append(a.Print());
                });
            return ret.ToString();
        }
        

        public List<TreeNode> AddRange(int f, int t) {
            List<TreeNode> tmp = new List<TreeNode>();
            for(int i=f; i<=t; i++) {
                tmp.Add(new TreeNode(i));
            }
            this.Items.AddRange(tmp);
            return tmp;
        }
    }

    public class Reader {
        public static bool IsDebug = true;
        private static System.IO.StringReader SReader;
        private static string InitText = @"


2 2 2 2




";
        public static string ReadLine() {
            if(IsDebug) {
                if(SReader == null) {
                    SReader = new System.IO.StringReader(InitText.Trim());
                }
                return SReader.ReadLine();
            } else {
                return Console.ReadLine();
            }
        }
    }
    public static void Main(string[] args)
    {
        Program prg = new Program();
        prg.Proc();
    }
}
0