• H. Huge Boxes of Animal Toys


    H. Huge Boxes of Animal Toys

    time limit per test

    2 seconds

    memory limit per test

    256 megabytes

    input

    standard input

    output

    standard output

    Chaneka has a hobby of playing with animal toys. Every toy has a different fun value, a real number. Chaneka has four boxes to store the toys with specification:

    • The first box stores toys with fun values in range of (−∞,−1](−∞,−1].
    • The second box stores toys with fun values in range of (−1,0)(−1,0).
    • The third box stores toys with fun values in range of (0,1)(0,1).
    • The fourth box stores toys with fun value in range of [1,∞)[1,∞).

    Chaneka has AA, BB, CC, DD toys in the first, second, third, and fourth box, respectively. One day she decides that she only wants one toy, a super toy. So she begins to create this super toy by sewing all the toys she has.

    While the number of toys Chaneka has is more than 1, she takes two different toys randomly and then sews them together, creating a new toy. The fun value of this new toy is equal to the multiplication of fun values of the sewn toys. She then puts this new toy in the appropriate box. She repeats this process until she only has one toy. This last toy is the super toy, and the box that stores this toy is the special box.

    As an observer, you only know the number of toys in each box initially but do not know their fun values. You also don't see the sequence of Chaneka's sewing. Determine which boxes can be the special box after Chaneka found her super toy.

    Input

    The first line has an integer TT (1≤T≤5⋅104)(1≤T≤5⋅104), the number of test cases.

    Every case contains a line with four space-separated integers AA BB CC DD (0≤A,B,C,D≤106,A+B+C+D>0)(0≤A,B,C,D≤106,A+B+C+D>0), which denotes the number of toys in the first, second, third, and fourth box, respectively.

    Output

    For each case, print four space-separated strings. Each string represents the possibility that the first, second, third, and fourth box can be the special box from left to right.

    For each box, print "Ya" (Without quotes, Indonesian for yes) if that box can be the special box. Print "Tidak" (Without quotes, Indonesian for No) otherwise.

    Example

    input

    Copy

    2
    1 2 0 1
    0 1 0 0
    

    output

    Copy

    Ya Ya Tidak Tidak
    Tidak Ya Tidak Tidak
    

    Note

    For the first case, here is a scenario where the first box is the special box:

    • The first box had toys with fun values {−3}{−3}.
    • The second box had toys with fun values {−0.5,−0.5}{−0.5,−0.5}
    • The fourth box had toys with fun values {3}{3}

    The sewing sequence:

    1. Chaneka sews the toy with fun −0.5−0.5 and −0.5−0.5 to a toy with fun 0.250.25 and then put it in the third box.
    2. Chaneka sews the toy with fun −3−3 and 0.250.25 to a toy with fun −0.75−0.75 and then put it in the second box.
    3. Chaneka sews the toy with fun −0.75−0.75 and 33 to a toy with fun −1.25−1.25 and then put it in the first box, which then became the special box.

    Here is a scenario where the second box ends up being the special box:

    • The first box had toys with fun values {−3}{−3}
    • The second box had toys with fun values {−0.33,−0.25}{−0.33,−0.25}.
    • The fourth box had toys with fun values {3}{3}.

    The sewing sequence:

    1. Chaneka sews the toy with fun −3−3 and −0.33−0.33 to a toy with fun 0.990.99 and then put it in the third box.
    2. Chaneka sews the toy with fun 0.990.99 and 33 to a toy with fun 2.972.97 and then put in it the fourth box.
    3. Chaneka sews the toy with fun 2.972.97 and −0.25−0.25 to a toy with fun −0.7425−0.7425 and then put it in the second box, which then became the special box.

    There is only one toy for the second case, so Chaneka does not have to sew anything because that toy, by definition, is the super toy.

    =========================================================================

    规律是一旦负数有奇数个,那么最终必定是负数

    考虑ABCD

    负数为奇数个时,如果A存在,那么最终一定可以落在A,即把A搞成最大,BC搞成1,D也搞成最大,如果A不存在,D存在的话,也是可以的,

    B存在,则一定可以生成B,把AD全部改成1即可,当然B不存在时如果C存在,也是可以的

    偶数个奇数时同理

    1. #include
    2. # include
    3. # include
    4. using namespace std;
    5. typedef long long int ll;
    6. void ans(bool x)
    7. {
    8. cout<<((x==0)?"Tidak ":"Ya ");
    9. }
    10. int main ()
    11. {
    12. int t;
    13. cin>>t;
    14. while(t--)
    15. {
    16. int a,b,c,d;
    17. cin>>a>>b>>c>>d;
    18. if((a+b)&1)
    19. {
    20. ans(a||d);
    21. ans(b||c);
    22. ans(0);
    23. ans(0);
    24. }
    25. else
    26. {
    27. ans(0);
    28. ans(0);
    29. ans(c||b);
    30. ans(d||a);
    31. }
    32. cout<
    33. }
    34. return 0;
    35. }

  • 相关阅读:
    【ES6】CommonJS模块和ES6模块
    【nlp】1.2文本张量表示方法(词向量word2seq和词嵌入Word Embedding)
    SSM+冬奥会志愿者招募系统 毕业设计-附源码191621
    软件的命令安装备份
    PAT 1029 旧键盘
    利用PHP快速抓取音频数据的方法与技巧
    Nvidia显卡Failed to initialize NVML Driver/library version mismatch错误解决方案
    3D可视化字母出现频率_vtkLinearExtrusionFilter
    Linux嵌入式I2C协议笔记
    Boost获取当前时间并格式化为字符串
  • 原文地址:https://blog.csdn.net/jisuanji2606414/article/details/126224801