A Few Laughing Men
A Few Laughing Men
Balaji is a great person to hang out with. He tells really amazing jokes, though sometimes he also slips some very boring ones in between. Today, he told N jokes to Arjun. We have this information in an array J of size N recorded and given to us by Vaibhav, where each entry can be either 1 or -1. 1 denotes that the joke was amazing, whereas -1 signifies the joke was boring and too poor to get even a forced smile from our nice Arjun.
Arjun being a sensible person, can distinguish amazing and boring jokes easily. He usually laughs only at amazing jokes. But today morning he had a session of laughter yoga, and he is very happy and elated. So, whenever he hears some amazing jokes, he laughs with strictly more intensity than the previous amazing joke that he heard. As usual, if you tell a boring joke, he won't care much about it and will respond arbitrarily. That is, you can't say anything about his laugh intensity. It could be anything.
Vaibhav was present during this laughing session. He recorded the events, but since he has not seen Arjun before, he is not sure if it was actually Arjun or someone else who was laughing. He has recorded the type of the N jokes in array J. Also, the laughter intensities were recorded in an array L of size N by an automated sophisticated equipment called the intensometer. The ith entry of this array denotes the intensity with which the person laughed at the ith joke. But we do not trust Vaibhav fully. Through our very trusted sources Animesh and Akashdeep, it came to light that Vaibhav might have slept for a short duration during the session. But we know that if at all he slept, he slept only for a short enough time and so he could only have miswritten the joke type of at most one joke. That is, he could have misclassified at most one amazing joke as a boring one, or vice-versa. As intensities are calculated using the intensometer, they have been recorded precisely and there are no errors in it.
So, given the array J, and the array L, we should identify whether the person laughing could have been Arjun or not. Note that Arjun could laugh at an amazing joke with intensity 0.
Input
The first line of the input contains an integer T denoting the number of test cases. The description of T cases follow.
The first line of each test case contains a single integer N denoting the number of jokes Balaji told.
The second line of each test case contains N space separated integers denoting the array J.
The third line of each test case contains N space separated integers denoting the array L.
Output
For each test case, output a single line containing "#laughing_arjun" or "#itsnot_arjun". You should output "#itsnot_arjun" if you are sure that the person whose laugh intensities have been recorded is not Arjun. But if it could be Arjun, you should output "#laughing_arjun".
Constraints
- 1 ≤ T ≤ 105
- 1 ≤ N ≤ 105
- Ji = 1 or -1
- 0 ≤ Li ≤ 109
- There will be no two jokes with the same intensity.
- Sum of N over all the test cases in a single file ≤ 106.
Example
Input
4
4
1 1 -1 1
1 3 2 4
4
1 1 -1 1
3 1 2 4
4
1 1 -1 1
4 3 2 1
4
-1 -1 -1 -1
4 3 2 1 Output
#laughing_arjun
#laughing_arjun
#itsnot_arjun
#laughing_arjun
Explanation
Example case 1. Only the third joke was boring. All other jokes were amazing. The person laughed in increasing intensity over the good jokes (1 3 4), so he could be Arjun.
Example case 2. Similar to the previous testcase, the third joke was boring. All other jokes were amazing. But the person didn't laugh in increasing intensity over the amazing jokes (3 1 4). However, Vaibhav might have been sleeping and he could have misrecorded the first joke as an amazing joke. In that case, the laughing intensities over the amazing jokes will be 1 4, which is in increasing order. So, this person could be Arjun.
Example case 3. The third joke was boring again. The person didn't laugh in increasing intensity over the amazing jokes (4 3 1). Even if Vaibhav was sleeping, the recorded intensities over the amazing jokes could only be (3, 1), (4, 1), or (4, 3). None of these are increasing, and so this person is definitely not Arjun.
Example case 4. All the jokes were boring. Arjun could have laughed in any intensity order. So this can be Arjun.
去掉一个看是不是递增序列
#include<stdio.h>
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lson l,mi,rt<<1
#define rson mi,r,rt<<1|1
#define dbg(x) cout<<#x<<" = "<< (x)<< endl
#define pb push_back
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define pll pair<long long,long long>
#define pii pair<int,int>
#define pq priority_queue
const int N=1e6+,MD=1e9+,INF=0x3f3f3f3f;
const ll LL_INF=0x3f3f3f3f3f3f3f3f;
const double eps=1e-,e=exp(),PI=acos(-.);
int a[N],b[N],sta[N];
int main()
{
ios::sync_with_stdio(false),cin.tie(),cout.tie();
int T;
cin>>T;
while(T--)
{
int n,tot=;
sta[]=-;
cin>>n;
for(int i=;i<n;i++)cin>>a[i];
for(int i=;i<n;i++)cin>>b[i];
int f1=,f2=;
for(int i=;i<n;i++)
{
if(a[i]==-)continue;
if(b[i]>sta[tot])sta[++tot]=b[i];
else if(f1)
{
f2=;
break;
}
else
f1=,sta[tot]=b[i]>sta[tot-]?b[i]:sta[tot];
}
printf(f2?"#itsnot_arjun\n":"#laughing_arjun\n");
}
return ;
}
A Few Laughing Men的更多相关文章
- Things about single men that women hate
Things about single men that women hate为何你俘获不了女神的心?If you listen in to a group of single women talki ...
- Men and women can't be 'just friends
Men and women can't be 'just friends' Can heterosexual men and women ever be "just friends" ...
- 广告狂人第一至七季/全集Mad Men迅雷下载
广告狂人 第一季 Mad Men Season 1 (2007) 本季看点:你是谁?你想要什么?你爱乾什么?这些都不重要,重要的是你怎么把东西卖出去.凡是了解纽约的人都知道,今天,在麦迪逊大道(Mad ...
- 好汉两个半第十二季/全集Two and a Half Men迅雷下载
本季Two And A Half Men Season 12 (2014)看点:<好汉两个半>的“半个”是因为第一季播出时杰克年纪太小,只能算半个.故事就在这三个主角和他们周围的女人中发生 ...
- 好汉两个半第一季/全集Two And A Half Men迅雷下载
第一季 Two and a Half Men Season 1 (2003)看点:Charlie是一个潇洒自由的单身汉,但正面临离婚危机的兄弟Alan带着儿子Jake的突然来访完全打乱了Charlie ...
- 每日英语:The Benefits of a Better Men's T-Shirt
"I WEAR A T-shirt and jeans every single day," said Erik Schnakenberg, 30, co-founder of t ...
- 每日英语:He Diets, She Diets: More Weight-Loss Plans Target Men
Weight-loss companies are becoming savvier about getting men to go on a diet. savvier:更加精明 Men and w ...
- All men are brothers
All men are brothers 牛客多校第九场E 给定n个人,起初互不认识 然后m各阶段 每个阶段有两个人x.y认识 求每个阶段选出四个人互不认识的方式 并查集 #include<bi ...
- 【Kata Daily 190919】Sort Out The Men From Boys(排序)
题目: Scenario Now that the competition gets tough it will Sort out the men from the boys . Men are th ...
随机推荐
- 为什么HDFS的副本数通常选择3?
HDFS采用一种称为机架感知的策略来改进数据的可靠性.可用性和网络带宽的利用率. 在大多数情况下,HDFS的副本系数是3,HDFS的存放策略是一个副本存放在本地机架节点上,另一个副本存放在同一机架的另 ...
- Windows 7, Visual Studio 2015下编译Webkit
因工作需要,需要编译Windows版本的Webkit,中间走了不少弯路,都记录下来,供大家参考!也随时欢迎大家讨论(QQ群:345802342) 整个编译工作参考的是官方文档:https://webk ...
- MovieReview—Wile Hunter(荒野猎人)
Faith is Power Faith is power, this sentence is not wrong. Find your own beliefs, and strug ...
- mysql中的空值问题
MySQL的查询如果需要用到空值的情况下,where后面的条件就需要注意了 MySQL中的表示空值的方法:is null 和 is not null 比如:select * from user whe ...
- helm install
reference 前提:已安装k8s:v1.10.4 helm install on master(无需下载官方tar包) 链接:https://pan.baidu.com/s/1Ji3Ru1pTQ ...
- linux ecrypt decrypt
reference ecrypt vickey | openssl enc -aes-256-cbc -a -salt -pass pass:wu decrypt echo U2FsdGVkX1+Hn ...
- Maven搭建Struts2+Spring3+Hibernate4框架
做了三年多的JavaEE开发了,在平时的JavaEE开发中,为了能够用最快的速度开发项目,一般都会选择使用Struts2,SpringMVC,Spring,Hibernate,MyBatis这些开源框 ...
- 01_9_ServletContext
01_9_ServletContext 1. 例子 public void doGet(HttpServletRequest request, HttpServletResponse response ...
- mysql 编程
一.存储函数 相当于php或者js中有返回值的函数 --完成一定“计算”后返回单个的数据值 定义: create function 函数名(parameter p1 value_type, param ...
- 事务控制语言DTL
一.什么是事务? · 数据库中的事务,是指可以将“多条相关语句执行”看做是“一条语句执行”的一种内部机制.即事务是一种可以保证“多条语句一次性执行完成”或者一条语句都不执行的机制. 三.事务的特点 原 ...