Submission #1056898


Source Code Expand

Copy
using System;
public class BaF {
    public static void Main() {
        string[] read = new string[4];
        read = Console.ReadLine().Split(' ');
        int sx = int.Parse(read[0]);
        int sy = int.Parse(read[1]);
        int tx = int.Parse(read[2]);
        int ty = int.Parse(read[3]);
        //int min = Math.Abs(sx - tx) + Math.Abs(sy-ty);
        string hp = "R";
        string hm = "L";
        string vp = "U";
        string vm = "D";
        string outp = "";
        if (sx > tx) {
            hp = "L";
            hm = "R";
        } else if (sx < tx) {
            hp = "R";
            hm = "L";
        }
        if (sy > ty) {
            vp = "D";
            vm = "U";
        } else if (sy < ty) {
            vp = "U";
            vm = "D";
        }
        if (sx != tx && sy != ty) {
            for (int i = 0; i < Math.Abs(sx - tx); i++) {
                outp += hp;
            }
            for (int i = 0; i < Math.Abs(sy - ty); i++) {
                outp += vp;
            }//行き1

            for (int i = 0; i < Math.Abs(sx - tx); i++) {
                outp += hm;
            }
            for (int i = 0; i < Math.Abs(sy - ty); i++) {
                outp += vm;
            }//帰り1

            outp += hm;//一回逃げる
            for (int i = 0; i < Math.Abs(sy - ty); i++) {
                outp += vp;
            }
            outp += vp;//もう一回逃げる
            for (int i = 0; i <= Math.Abs(sx - tx); i++) {//一回目の逃げ分補正
                outp += hp;
            }
            outp += vm;//二回目の逃げ分補正、ここまで行き2

            outp += hp;//一回逃げ
            for (int i = 0; i <= Math.Abs(sy - ty); i++) {//もう一回逃げ
                outp += vm;
            }
            for (int i = 0; i <= Math.Abs(sx - tx); i++) {//一回目の逃げ補正
                outp += hm;
            }
            outp += vp;//二回目の逃げ補正
        } else if (sy == ty) {
            for (int i = 0; i < Math.Abs(sx - tx); i++) {
                outp += hp;
            }//直線,行き1

            outp += vp;//一回逃げ
            for (int i = 0; i < Math.Abs(sx - tx); i++) {
                outp += hm;
            }//直線
            outp += vm;//逃げ補正、帰り1

            outp += vm;//一回逃げ
            for (int i = 0; i < Math.Abs(sx - tx); i++) {
                outp += hp;
            }//直線
            outp += vp;//逃げ補正、行き2

            outp += hp;//逃げ
            outp += vp;
            outp += vp;//逃げ*2
            for (int i = 0; i < Math.Abs(sx - tx) + 2; i++) {
                outp += hm;
            }//直線+2補正
            outp += vm;
            outp += vm;//補正*2
            outp += hp;//補正
        } else if (sx == tx) {
            for (int i = 0; i < Math.Abs(sy - ty); i++) {
                outp += vp;
            }//直線,行き1

            outp += hp;//一回逃げ
            for (int i = 0; i < Math.Abs(sy - ty); i++) {
                outp += vm;
            }//直線
            outp += hm;//逃げ補正、帰り1

            outp += hm;//一回逃げ
            for (int i = 0; i < Math.Abs(sy - ty); i++) {
                outp += vp;
            }//直線
            outp += hp;//逃げ補正、行き2

            outp += vp;//逃げ
            outp += hp;
            outp += hp;//逃げ*2
            for (int i = 0; i < Math.Abs(sy - ty) + 2; i++) {
                outp += vm;
            }//直線+2補正
            outp += hm;
            outp += hm;//補正*2
            outp += vp;//補正
        }
        Console.WriteLine(outp);
    }
}

Submission Info

Submission Time
Task C - Back and Forth
User shomu36
Language C# (Mono 4.6.2.0)
Score 300
Code Size 3812 Byte
Status
Exec Time 339 ms
Memory 26568 KB

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 sample_01.txt, sample_02.txt
All 300 / 300 subtask_1_01.txt, subtask_1_02.txt, subtask_1_03.txt, subtask_1_04.txt, subtask_1_05.txt, subtask_1_06.txt, subtask_1_07.txt, subtask_1_08.txt, subtask_1_09.txt, subtask_1_10.txt
Case Name Status Exec Time Memory
sample_01.txt 20 ms 2776 KB
sample_02.txt 19 ms 2648 KB
subtask_1_01.txt 19 ms 2648 KB
subtask_1_02.txt 339 ms 26568 KB
subtask_1_03.txt 84 ms 26568 KB
subtask_1_04.txt 40 ms 17608 KB
subtask_1_05.txt 25 ms 6744 KB
subtask_1_06.txt 19 ms 2776 KB
subtask_1_07.txt 19 ms 2648 KB
subtask_1_08.txt 26 ms 6744 KB
subtask_1_09.txt 58 ms 26568 KB
subtask_1_10.txt 26 ms 6744 KB