A Few Laughing Men

CodeChef - LAUGHMEN

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的更多相关文章

  1. 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 ...

  2. 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" ...

  3. 广告狂人第一至七季/全集Mad Men迅雷下载

    广告狂人 第一季 Mad Men Season 1 (2007) 本季看点:你是谁?你想要什么?你爱乾什么?这些都不重要,重要的是你怎么把东西卖出去.凡是了解纽约的人都知道,今天,在麦迪逊大道(Mad ...

  4. 好汉两个半第十二季/全集Two and a Half Men迅雷下载

    本季Two And A Half Men Season 12 (2014)看点:<好汉两个半>的“半个”是因为第一季播出时杰克年纪太小,只能算半个.故事就在这三个主角和他们周围的女人中发生 ...

  5. 好汉两个半第一季/全集Two And A Half Men迅雷下载

    第一季 Two and a Half Men Season 1 (2003)看点:Charlie是一个潇洒自由的单身汉,但正面临离婚危机的兄弟Alan带着儿子Jake的突然来访完全打乱了Charlie ...

  6. 每日英语: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 ...

  7. 每日英语: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 ...

  8. All men are brothers

    All men are brothers 牛客多校第九场E 给定n个人,起初互不认识 然后m各阶段 每个阶段有两个人x.y认识 求每个阶段选出四个人互不认识的方式 并查集 #include<bi ...

  9. 【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 ...

随机推荐

  1. 【装载】删除Oracle11G

    卸载Oracle步骤:1.停止所有与ORACLE相关的服务.2. 使用OUI(Oracle Universal Installer)卸载Oracle软件.   “开始”->“程序”->“O ...

  2. iOS优化

    load妙用 aop面向切面编程 NSNumber Or Int @()适配64位 经过漫长时间的学习 你终于掌握了iOS大法 你找到了份iOS开发的工作 信誓旦旦的要开始你的coding生涯 老板对 ...

  3. ASP.NET WebForm & MongoDB

    ASP.NET WebForm & MongoDB 最近在朋友介绍下,也跟着看AngularJS 买了一本三合一的书,Node.JS+MongoDB+AngularJS http://www. ...

  4. lwz程序人生之启程

    本人14年小本科毕业. 第一次接触电脑是小学4年级.当时,是小学公开课,老师让我们去电脑室秀一下.现在,我都记不得当时我第一次看到电脑室好奇呢?还是没感觉呢? 到初中上电脑课的时候,我才真正了解到电脑 ...

  5. UVA 1152 4 Values Whose Sum is Zero 和为0的4个值 (中途相遇)

    摘要:中途相遇.对比map,快排+二分查找,Hash效率. n是4000的级别,直接O(n^4)肯定超,所以中途相遇法,O(n^2)的时间枚举其中两个的和,O(n^2)的时间枚举其他两个的和的相反数, ...

  6. Spring boot 集成ActiveMQ(包含双向队列实现)

    集百家之长,成一家之言.  1. 下载ActiveMQ https://mirrors.tuna.tsinghua.edu.cn/apache/activemq/5.15.9/apache-activ ...

  7. MFC多文档无法显示可停靠窗格

    当我们使用MFC多文档创建项目时,我们可停靠窗格关闭之后就无法显示了.即使重新编译项目也无法再次显示它们. 原因:因为MFC多文档把这些设置存储在注册表 “HKEY_CURRENT_USER \ SO ...

  8. Golang glog使用详解

    golang/glog 是 C++ 版本 google/glog 的 Go 版本实现,基本实现了原生 glog 的日志格式.在 Kuberntes 中,glog 是默认日志库. glog 的使用与特性 ...

  9. ps基础实例

    一:合并多个图片 1.先新件一个图片)CTRL+N),大小定成你想要的大小 2.把你要放入的照片用PS打开 3.把放入的照片用移动工具(V)拉到新件的图片里面 4.用CTRL+T调整大小(按住SHIF ...

  10. CentOS 编译安装PHP5.6(7以上也通用)

    由于公司有新服务器需要构建一套LNMP平台,且需要编译安装各个部件,所以记录下此文章. 这是安装PHP涉及到的软件包(可以自行决定使用哪个版本): ├── libiconv-1.15.tar.gz ├ ...