当前位置:网站首页>H. Huge Boxes of Animal Toys
H. Huge Boxes of Animal Toys
2022-08-08 16:37:00 【秦小咩】
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:
- 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.
- 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.
- 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:
- 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.
- 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.
- 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存在,也是可以的
偶数个奇数时同理
#include<iostream>
# include<algorithm>
# include<unordered_map>
using namespace std;
typedef long long int ll;
void ans(bool x)
{
cout<<((x==0)?"Tidak ":"Ya ");
}
int main ()
{
int t;
cin>>t;
while(t--)
{
int a,b,c,d;
cin>>a>>b>>c>>d;
if((a+b)&1)
{
ans(a||d);
ans(b||c);
ans(0);
ans(0);
}
else
{
ans(0);
ans(0);
ans(c||b);
ans(d||a);
}
cout<<endl;
}
return 0;
}
边栏推荐
- 找工作的我看了国聘app
- bzoj5063 旅游
- Grafana配置LDAP认证
- 使用 FasterTransformer 和 Triton 推理服务器加速大型 Transformer 模型的推理
- 【uniapp小程序】视图容器cover-view
- Subject: Ordered Queue
- MySQL中常见的内些...啥
- 【论文阅读】RAL 2022: Receding Moving Object Segmentation in 3D LiDAR Data Using Sparse 4D Convolutions
- 【 8.7 】 source code - card to LCM with GCD 】 【 】
- 淘宝API常用接口列表与申请方式
猜你喜欢
随机推荐
NFT质押挖矿分红系统开发逻辑功能介绍
Solve the inexplicable problem of MySQL violently - restart the service!
我分析30w条数据后发现,西安新房公摊最低的竟是这里?
【uniapp小程序】视图容器cover-view
好用的项目工时管理系统有哪些
Using PyGame's Bubble Sort Visualizer
产品经理常用的19类50+工具软件盘点
2022年11大最佳缺陷管理工具盘点
基于ECS实现一分钟自动化部署【华为云至简致远】
【8.7】代码源 - 【抽卡】【LCM与GCD】
3 个开源项目,让你感受程序员的浪漫!
pdf导出工具类
基于FTP协议的Excel文件上传与下载
ImportError: numpy.core.multiarray failed to import [cv2, matplotlib, PyTorch, pyinstaller ]
五、jmeter脚本的基本构成&断言
一、根据系统架构定位系统性能瓶颈
C语言学习概览(六)
基于华为云ModelArts的水表读数识别开发实践【华为云至简致远】
项目管理流程包含哪些
国内部分手机游戏开始显示用户IP属地