Submission #155361


Source Code Expand

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace MixTester
{
    class Program
    {
        public static TextReader input;
        public static TextWriter output;


        public static List<int> ResidueList(int half_)
        {
            List<int> result = new List<int>();
            for (int i = 1; i <= half_; i++)
            {
                if (half_ % i == 0)
                    result.Add(i);
            }

            return result;
        }
        public static void Main(string[] args)
        {
            #region
            //Initialize
            input = Console.In;
            output = Console.Out;
            //input = new StreamReader("power.txt");
            //output = new StreamWriter("send.txt");
            //EndInitialize
            #endregion
            //ABC006
            //A
            /*
            int N = ReadInteger(1)[0];

            if (N % 3 == 0)
                output.WriteLine("YES");
            else
                output.WriteLine("NO");
             * */
            //B
            /*
            int N = ReadInteger(1)[0];
            ModularInteger pre2 = new ModularInteger(0), pre1 = new ModularInteger(0), now = new ModularInteger(1);

            ModularInteger answer;

            if (N < 3)
                answer = new ModularInteger(0);
            else
            {
                answer = now;
                for (int i = 0; i < N - 3; i++)
                {
                    answer = pre2 + pre1 + now;
                    pre2 = pre1;
                    pre1 = now;
                    now = answer;
                }
            }

            output.WriteLine(answer);
            */
            //C
            int[] start = ReadInteger(2);
            int head = start[0];
            int leg = start[1];

            if (leg < 2 * head || leg > 4 * head)
                output.WriteLine("-1 -1 -1");
            else if (leg < 3 * head)
            {
                int diff = 3 * head - leg;
                int roujin = head - diff;
                int adult = diff;
                output.WriteLine(string.Format("{0} {1} 0", adult, roujin));
            }
            else
            {
                int diff = leg - 3 * head;
                int roujin = head - diff;
                int child = diff;
                output.WriteLine(string.Format("0 {0} {1}", roujin, child));
            }

        
        }
        public static int[] ReadInteger(int count_)
        {
            int[] result = new int[count_];
            string line = input.ReadLine();
            string[] parts = line.Split(' ', ':', '/');
            for (int i = 0; i < count_; i++)
            {
                result[i] = int.Parse(parts[i]);
            }

            return result;

        }
    }

    struct ModularInteger : IComparable
    {
        /// <summary>
        /// この値はint maxの半分未満にしてください
        /// </summary>
        public const int MODULO = 10007;

        private long m_value;

        public long Value
        {
            get { return this.m_value; }
            private set { this.m_value = value; }
        }

        public ModularInteger(long initialvalue_)
            : this()
        {
            if (initialvalue_ >= 0)
                Value = initialvalue_ % MODULO;
            else
                Value = (initialvalue_ % MODULO) + MODULO;
        }

        public static ModularInteger operator +(ModularInteger left_, ModularInteger right_)
        {
            return new ModularInteger(left_.Value + right_.Value);
        }
        public static ModularInteger operator -(ModularInteger left_, ModularInteger right_)
        {
            return new ModularInteger(left_.Value - right_.Value);
        }
        public static ModularInteger operator *(ModularInteger left_, ModularInteger right_)
        {
            return new ModularInteger(left_.Value * right_.Value);
        }
        public static bool operator >(ModularInteger left_, ModularInteger right_)
        {
            return left_.Value > right_.Value;
        }
        public static bool operator <(ModularInteger left_, ModularInteger right_)
        {
            return left_.Value < right_.Value;
        }
        public override string ToString()
        {
            return m_value.ToString();
        }

        int IComparable.CompareTo(object obj)
        {
            return (int)(this.m_value - ((ModularInteger)obj).m_value);
        }
    }


   
    class BinaryHeap<T> : PriorityQueue<T>
    {
        private FlexibleArray<T> m_implearray;

        private IComparer<T> m_comparer;

        private delegate int MyComparer(T a_, T b_);

        public BinaryHeap(IComparer<T> comparer_, int initialsize_ = 128)
        {
            /*
            try
            {
                MyComparer comparer = (T a_, T b_) =>
                {
                    IComparable comparable_a = (IComparable)a_;
                    return comparable_a.CompareTo(b_);
                };
            }*/
            m_implearray = new FlexibleArray<T>(initialsize_);
            m_comparer = comparer_;
        }

        /// <summary>
        /// 指定されたインデックスの親のインデックスを返します。
        /// </summary>
        /// <param name="childindex_">子ノードのインデックス</param>
        /// <returns></returns>
        private static int ParentIndex(int childindex_)
        {
            return (childindex_ - 1) / 2;
        }

        /// <summary>
        /// 指定されたインデックスの左側の子のインデックスを返します。
        /// </summary>
        /// <param name="parentindex_"></param>
        /// <returns></returns>
        private static int ChildFirstIndex(int parentindex_)
        {
            return parentindex_ * 2 + 1;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="parentindex_"></param>
        /// <returns></returns>
        private static int ChildSecondIndex(int parentindex_)
        {
            return parentindex_ * 2 + 2;
        }

        public override void Enqueue(T element_)
        {
            //まずは指定された要素を末尾に追加
            m_implearray.PushBack(element_);
            //親と比較して、親より小さかったら(優先度が高かったら)親と交換する
            int lastindex = m_implearray.Length - 1;
            while (m_comparer.Compare(m_implearray[ParentIndex(lastindex)], m_implearray[lastindex]) > 0)
            {
                m_implearray.Swap(lastindex, ParentIndex(lastindex));
                lastindex = ParentIndex(lastindex);
            }
        }

        public bool Empty
        {
            get { return m_implearray.Length <= 0; }
        }

        public override T Dequeue()
        {
            //キューが空の時はnullを返す
            if (this.Empty)
            {
                throw new Exception("Queue is Empty");
            }
            //ルートと最後の葉を入れ替える
            m_implearray.Swap(0, m_implearray.Length - 1);
            //出力を準備しておく
            T front = m_implearray.PopBack();
            //現在ルートが大きい値になってしまっている。
            //2つの子が両方あるなら、その小さい方と交換
            int parentindex = 0;
            while (true)
            {
                int childleft = ChildFirstIndex(parentindex);
                int childright = ChildSecondIndex(parentindex);
                if (m_implearray.IndexChecker(childleft) && m_implearray.IndexChecker(childright))
                {
                    //子のどちらかよりも大きかった場合
                    if (m_comparer.Compare(m_implearray[childleft], m_implearray[parentindex]) <= 0 ||
                        m_comparer.Compare(m_implearray[childright], m_implearray[parentindex]) <= 0)
                    {
                        //左と右を比較して、より小さい方と交換
                        if (m_comparer.Compare(m_implearray[childleft], m_implearray[childright]) < 0)
                        {
                            m_implearray.Swap(childleft, parentindex);
                            parentindex = childleft;
                        }
                        else
                        {
                            m_implearray.Swap(childright, parentindex);
                            parentindex = childright;
                        }
                    }
                    //子のどちらよりもすでに小さかった場合は終了
                    else
                    {
                        break;
                    }
                }
                //片方の左側しか存在しない場合は、左側とだけ比べる
                else if (m_implearray.IndexChecker(childleft))
                {
                    if (m_comparer.Compare(m_implearray[childleft], m_implearray[parentindex]) < 0)
                    {
                        m_implearray.Swap(childleft, parentindex);
                        parentindex = childleft;
                    }
                    //比べた結果左の子以下だった場合は終了
                    else
                    {
                        break;
                    }
                }
                //そもそももう子供がいない場合は終了
                else
                {
                    break;
                }
            }
            return front;
        }

        public override T PeekFront()
        {
            return m_implearray[0];
        }
    }

    class BinaryHeap<TKey, TValue> where TKey : IComparable
    {
    }

    abstract class PriorityQueue<T>
    {
        public abstract void Enqueue(T element_);

        public abstract T Dequeue();

        public abstract T PeekFront();
    }

    class FlexibleArray<T> : IEnumerable<T>
    {
        private int m_nextindex;

        private T[] m_bodyarray;

        public FlexibleArray(int initalsize_ = 128)
        {
            m_nextindex = 0;
            m_bodyarray = new T[initalsize_];
        }

        public void PushBack(T element_)
        {
            //配列サイズをオーバーしてしまったら中身の配列を2倍に拡大
            if (m_nextindex >= m_bodyarray.Length)
                this.ExtendSize(m_nextindex * 2);
            m_bodyarray[m_nextindex] = element_;
            m_nextindex += 1;
        }

        public T PopBack()
        {
            m_nextindex -= 1;
            return m_bodyarray[m_nextindex];
        }

        public void Swap(int a_, int b_)
        {
            T temp;
            temp = m_bodyarray[a_];
            m_bodyarray[a_] = m_bodyarray[b_];
            m_bodyarray[b_] = temp;
        }

        public bool IndexChecker(int index_)
        {
            return index_ >= 0 && index_ < m_nextindex;
        }

        public int Length
        {
            get { return m_nextindex; }
        }

        public T this[int index_]
        {
            get
            {
                if (index_ >= 0 && index_ < m_nextindex)
                    return m_bodyarray[index_];
                else
                    throw new IndexOutOfRangeException();
            }
        }

        private void ExtendSize(int newsize_)
        {
            if (m_bodyarray.Length >= newsize_)
            {
                throw new ArgumentException();
            }
            T[] newarray = new T[newsize_];
            m_bodyarray.CopyTo(newarray, 0);
            m_bodyarray = newarray;
        }

        IEnumerator<T> IEnumerable<T>.GetEnumerator()
        {
            throw new NotImplementedException();
        }

        System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
        {
            throw new NotImplementedException();
        }
    }
}

Submission Info

Submission Time
Task C - スフィンクスのなぞなぞ
User koten_under
Language C# (Mono 2.10.8.1)
Score 100
Code Size 12485 Byte
Status AC
Exec Time 210 ms
Memory 7984 KB

Judge Result

Set Name smallA smallB all
Score / Max Score 10 / 10 20 / 20 70 / 70
Status
AC × 38
AC × 65
AC × 118
Set Name Test Cases
smallA test_1-1_ABC.txt, test_1-500_ABC.txt, test_100-103_ABC.txt, test_100-199_ABC.txt, test_100-1_ABC.txt, test_100-200_ABC.txt, test_100-201_ABC.txt, test_100-229_ABC.txt, test_100-300_ABC.txt, test_100-301_ABC.txt, test_100-399_ABC.txt, test_100-400_ABC.txt, test_100-401_ABC.txt, test_100-431_ABC.txt, test_100-473_ABC.txt, test_100-500_ABC.txt, test_33-106_ABC.txt, test_33-131_ABC.txt, test_33-132_ABC.txt, test_33-133_ABC.txt, test_33-134_ABC.txt, test_33-146_ABC.txt, test_33-51_ABC.txt, test_33-65_ABC.txt, test_33-66_ABC.txt, test_33-67_ABC.txt, test_33-71_ABC.txt, test_92-183_ABC.txt, test_92-184_ABC.txt, test_92-185_ABC.txt, test_92-310_ABC.txt, test_92-34_ABC.txt, test_92-367_ABC.txt, test_92-368_ABC.txt, test_92-369_ABC.txt, test_92-391_ABC.txt, test_92-434_ABC.txt, test_92-459_ABC.txt
smallB test_1-1_ABC.txt, test_1-500_ABC.txt, test_1-7500_AB.txt, test_100-103_ABC.txt, test_100-199_ABC.txt, test_100-1_ABC.txt, test_100-200_ABC.txt, test_100-201_ABC.txt, test_100-229_ABC.txt, test_100-300_ABC.txt, test_100-301_ABC.txt, test_100-399_ABC.txt, test_100-400_ABC.txt, test_100-401_ABC.txt, test_100-431_ABC.txt, test_100-473_ABC.txt, test_100-500_ABC.txt, test_100-7500_AB.txt, test_1500-1_AB.txt, test_1500-2999_AB.txt, test_1500-3000_AB.txt, test_1500-3001_AB.txt, test_1500-4072_AB.txt, test_1500-477_AB.txt, test_1500-500_AB.txt, test_1500-5768_AB.txt, test_1500-5999_AB.txt, test_1500-6000_AB.txt, test_1500-6001_AB.txt, test_1500-6268_AB.txt, test_1500-7024_AB.txt, test_1500-7500_AB.txt, test_33-106_ABC.txt, test_33-131_ABC.txt, test_33-132_ABC.txt, test_33-133_ABC.txt, test_33-134_ABC.txt, test_33-146_ABC.txt, test_33-51_ABC.txt, test_33-65_ABC.txt, test_33-66_ABC.txt, test_33-67_ABC.txt, test_33-71_ABC.txt, test_578-114_AB.txt, test_578-1155_AB.txt, test_578-1156_AB.txt, test_578-1157_AB.txt, test_578-1984_AB.txt, test_578-2101_AB.txt, test_578-2230_AB.txt, test_578-2311_AB.txt, test_578-2312_AB.txt, test_578-2313_AB.txt, test_578-2728_AB.txt, test_92-183_ABC.txt, test_92-184_ABC.txt, test_92-185_ABC.txt, test_92-310_ABC.txt, test_92-34_ABC.txt, test_92-367_ABC.txt, test_92-368_ABC.txt, test_92-369_ABC.txt, test_92-391_ABC.txt, test_92-434_ABC.txt, test_92-459_ABC.txt
all test_1-1_ABC.txt, test_1-500000_A.txt, test_1-500_ABC.txt, test_1-7500_AB.txt, test_100-103_ABC.txt, test_100-199_ABC.txt, test_100-1_ABC.txt, test_100-200_ABC.txt, test_100-201_ABC.txt, test_100-229_ABC.txt, test_100-300_ABC.txt, test_100-301_ABC.txt, test_100-399_ABC.txt, test_100-400_ABC.txt, test_100-401_ABC.txt, test_100-431_ABC.txt, test_100-473_ABC.txt, test_100-500000_A.txt, test_100-500_ABC.txt, test_100-7500_AB.txt, test_100000-175737_A.txt, test_100000-199999_A.txt, test_100000-1_A.txt, test_100000-200000_A.txt, test_100000-200001_A.txt, test_100000-300000_A.txt, test_100000-300001_A.txt, test_100000-321428_A.txt, test_100000-383852_A.txt, test_100000-399999_A.txt, test_100000-400000_A.txt, test_100000-400001_A.txt, test_100000-461143_A.txt, test_100000-482033_A.txt, test_100000-500000_A.txt, test_100000-500_A.txt, test_100000-7500_A.txt, test_12376-24751_A.txt, test_12376-24752_A.txt, test_12376-24753_A.txt, test_12376-4187_A.txt, test_12376-46199_A.txt, test_12376-49503_A.txt, test_12376-49504_A.txt, test_12376-49505_A.txt, test_12376-53158_A.txt, test_12376-57785_A.txt, test_12376-60441_A.txt, test_1500-1_AB.txt, test_1500-2999_AB.txt, test_1500-3000_AB.txt, test_1500-3001_AB.txt, test_1500-4072_AB.txt, test_1500-477_AB.txt, test_1500-500000_A.txt, test_1500-500_AB.txt, test_1500-5768_AB.txt, test_1500-5999_AB.txt, test_1500-6000_AB.txt, test_1500-6001_AB.txt, test_1500-6268_AB.txt, test_1500-7024_AB.txt, test_1500-7500_AB.txt, test_1931-2546_A.txt, test_1931-3861_A.txt, test_1931-3862_A.txt, test_1931-3863_A.txt, test_1931-6721_A.txt, test_1931-7547_A.txt, test_1931-7723_A.txt, test_1931-7724_A.txt, test_1931-7725_A.txt, test_1931-8765_A.txt, test_1931-9463_A.txt, test_33-106_ABC.txt, test_33-131_ABC.txt, test_33-132_ABC.txt, test_33-133_ABC.txt, test_33-134_ABC.txt, test_33-146_ABC.txt, test_33-51_ABC.txt, test_33-65_ABC.txt, test_33-66_ABC.txt, test_33-67_ABC.txt, test_33-71_ABC.txt, test_578-114_AB.txt, test_578-1155_AB.txt, test_578-1156_AB.txt, test_578-1157_AB.txt, test_578-1984_AB.txt, test_578-2101_AB.txt, test_578-2230_AB.txt, test_578-2311_AB.txt, test_578-2312_AB.txt, test_578-2313_AB.txt, test_578-2728_AB.txt, test_84391-168781_A.txt, test_84391-168782_A.txt, test_84391-168783_A.txt, test_84391-263979_A.txt, test_84391-294799_A.txt, test_84391-337563_A.txt, test_84391-337564_A.txt, test_84391-337565_A.txt, test_84391-407535_A.txt, test_84391-420642_A.txt, test_84391-98907_A.txt, test_92-183_ABC.txt, test_92-184_ABC.txt, test_92-185_ABC.txt, test_92-310_ABC.txt, test_92-34_ABC.txt, test_92-367_ABC.txt, test_92-368_ABC.txt, test_92-369_ABC.txt, test_92-391_ABC.txt, test_92-434_ABC.txt, test_92-459_ABC.txt
Case Name Status Exec Time Memory
sample_01.txt AC 210 ms 7852 KB
sample_02.txt AC 158 ms 7876 KB
sample_03.txt AC 146 ms 7500 KB
test_1-1_ABC.txt AC 152 ms 7536 KB
test_1-500000_A.txt AC 149 ms 7500 KB
test_1-500_ABC.txt AC 141 ms 7620 KB
test_1-7500_AB.txt AC 147 ms 7508 KB
test_100-103_ABC.txt AC 144 ms 7564 KB
test_100-199_ABC.txt AC 138 ms 7508 KB
test_100-1_ABC.txt AC 143 ms 7508 KB
test_100-200_ABC.txt AC 155 ms 7852 KB
test_100-201_ABC.txt AC 158 ms 7908 KB
test_100-229_ABC.txt AC 154 ms 7832 KB
test_100-300_ABC.txt AC 157 ms 7836 KB
test_100-301_ABC.txt AC 161 ms 7896 KB
test_100-399_ABC.txt AC 158 ms 7836 KB
test_100-400_ABC.txt AC 155 ms 7836 KB
test_100-401_ABC.txt AC 146 ms 7500 KB
test_100-431_ABC.txt AC 154 ms 7508 KB
test_100-473_ABC.txt AC 159 ms 7556 KB
test_100-500000_A.txt AC 142 ms 7504 KB
test_100-500_ABC.txt AC 145 ms 7504 KB
test_100-7500_AB.txt AC 147 ms 7508 KB
test_100000-175737_A.txt AC 148 ms 7540 KB
test_100000-199999_A.txt AC 150 ms 7504 KB
test_100000-1_A.txt AC 150 ms 7540 KB
test_100000-200000_A.txt AC 159 ms 7840 KB
test_100000-200001_A.txt AC 162 ms 7836 KB
test_100000-300000_A.txt AC 155 ms 7944 KB
test_100000-300001_A.txt AC 157 ms 7836 KB
test_100000-321428_A.txt AC 158 ms 7908 KB
test_100000-383852_A.txt AC 157 ms 7964 KB
test_100000-399999_A.txt AC 160 ms 7832 KB
test_100000-400000_A.txt AC 160 ms 7832 KB
test_100000-400001_A.txt AC 165 ms 7508 KB
test_100000-461143_A.txt AC 150 ms 7504 KB
test_100000-482033_A.txt AC 144 ms 7508 KB
test_100000-500000_A.txt AC 144 ms 7508 KB
test_100000-500_A.txt AC 147 ms 7524 KB
test_100000-7500_A.txt AC 143 ms 7508 KB
test_12376-24751_A.txt AC 147 ms 7536 KB
test_12376-24752_A.txt AC 160 ms 7952 KB
test_12376-24753_A.txt AC 156 ms 7840 KB
test_12376-4187_A.txt AC 147 ms 7556 KB
test_12376-46199_A.txt AC 156 ms 7960 KB
test_12376-49503_A.txt AC 155 ms 7836 KB
test_12376-49504_A.txt AC 157 ms 7900 KB
test_12376-49505_A.txt AC 149 ms 7544 KB
test_12376-53158_A.txt AC 144 ms 7508 KB
test_12376-57785_A.txt AC 147 ms 7508 KB
test_12376-60441_A.txt AC 149 ms 7620 KB
test_1500-1_AB.txt AC 146 ms 7556 KB
test_1500-2999_AB.txt AC 143 ms 7504 KB
test_1500-3000_AB.txt AC 155 ms 7840 KB
test_1500-3001_AB.txt AC 157 ms 7852 KB
test_1500-4072_AB.txt AC 160 ms 7964 KB
test_1500-477_AB.txt AC 147 ms 7504 KB
test_1500-500000_A.txt AC 146 ms 7508 KB
test_1500-500_AB.txt AC 143 ms 7540 KB
test_1500-5768_AB.txt AC 157 ms 7824 KB
test_1500-5999_AB.txt AC 155 ms 7896 KB
test_1500-6000_AB.txt AC 157 ms 7948 KB
test_1500-6001_AB.txt AC 142 ms 7508 KB
test_1500-6268_AB.txt AC 144 ms 7628 KB
test_1500-7024_AB.txt AC 142 ms 7504 KB
test_1500-7500_AB.txt AC 147 ms 7504 KB
test_1931-2546_A.txt AC 144 ms 7492 KB
test_1931-3861_A.txt AC 144 ms 7552 KB
test_1931-3862_A.txt AC 155 ms 7952 KB
test_1931-3863_A.txt AC 156 ms 7836 KB
test_1931-6721_A.txt AC 159 ms 7884 KB
test_1931-7547_A.txt AC 162 ms 7880 KB
test_1931-7723_A.txt AC 158 ms 7820 KB
test_1931-7724_A.txt AC 156 ms 7836 KB
test_1931-7725_A.txt AC 145 ms 7508 KB
test_1931-8765_A.txt AC 144 ms 7508 KB
test_1931-9463_A.txt AC 144 ms 7572 KB
test_33-106_ABC.txt AC 156 ms 7832 KB
test_33-131_ABC.txt AC 156 ms 7892 KB
test_33-132_ABC.txt AC 157 ms 7960 KB
test_33-133_ABC.txt AC 145 ms 7488 KB
test_33-134_ABC.txt AC 145 ms 7564 KB
test_33-146_ABC.txt AC 147 ms 7504 KB
test_33-51_ABC.txt AC 144 ms 7500 KB
test_33-65_ABC.txt AC 151 ms 7632 KB
test_33-66_ABC.txt AC 155 ms 7956 KB
test_33-67_ABC.txt AC 158 ms 7884 KB
test_33-71_ABC.txt AC 158 ms 7888 KB
test_578-114_AB.txt AC 145 ms 7512 KB
test_578-1155_AB.txt AC 143 ms 7508 KB
test_578-1156_AB.txt AC 160 ms 7892 KB
test_578-1157_AB.txt AC 158 ms 7984 KB
test_578-1984_AB.txt AC 154 ms 7904 KB
test_578-2101_AB.txt AC 162 ms 7844 KB
test_578-2230_AB.txt AC 158 ms 7904 KB
test_578-2311_AB.txt AC 157 ms 7900 KB
test_578-2312_AB.txt AC 159 ms 7964 KB
test_578-2313_AB.txt AC 145 ms 7508 KB
test_578-2728_AB.txt AC 148 ms 7508 KB
test_84391-168781_A.txt AC 144 ms 7540 KB
test_84391-168782_A.txt AC 158 ms 7832 KB
test_84391-168783_A.txt AC 158 ms 7820 KB
test_84391-263979_A.txt AC 157 ms 7860 KB
test_84391-294799_A.txt AC 154 ms 7964 KB
test_84391-337563_A.txt AC 154 ms 7964 KB
test_84391-337564_A.txt AC 158 ms 7904 KB
test_84391-337565_A.txt AC 147 ms 7508 KB
test_84391-407535_A.txt AC 145 ms 7504 KB
test_84391-420642_A.txt AC 145 ms 7508 KB
test_84391-98907_A.txt AC 148 ms 7508 KB
test_92-183_ABC.txt AC 146 ms 7508 KB
test_92-184_ABC.txt AC 156 ms 7888 KB
test_92-185_ABC.txt AC 158 ms 7952 KB
test_92-310_ABC.txt AC 154 ms 7836 KB
test_92-34_ABC.txt AC 147 ms 7552 KB
test_92-367_ABC.txt AC 163 ms 7904 KB
test_92-368_ABC.txt AC 161 ms 7832 KB
test_92-369_ABC.txt AC 146 ms 7544 KB
test_92-391_ABC.txt AC 146 ms 7504 KB
test_92-434_ABC.txt AC 143 ms 7540 KB
test_92-459_ABC.txt AC 145 ms 7520 KB