zoukankan      html  css  js  c++  java
  • A Few Laughing Men

    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+5,MD=1e9+7,INF=0x3f3f3f3f;
    const ll LL_INF=0x3f3f3f3f3f3f3f3f;
    const double eps=1e-9,e=exp(1),PI=acos(-1.);
    int a[N],b[N],sta[N];
    int main()
    {
        ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
        int T;
        cin>>T;
        while(T--)
        {
            int n,tot=0;
            sta[0]=-1;
            cin>>n;
            for(int i=0;i<n;i++)cin>>a[i];
            for(int i=0;i<n;i++)cin>>b[i];
            int f1=0,f2=0;
            for(int i=0;i<n;i++)
            {
                if(a[i]==-1)continue;
                if(b[i]>sta[tot])sta[++tot]=b[i];
                else if(f1)
                {
                    f2=1;
                    break;
                }
                else
                    f1=1,sta[tot]=b[i]>sta[tot-1]?b[i]:sta[tot];
            }
            printf(f2?"#itsnot_arjun
    ":"#laughing_arjun
    ");
        }
        return 0;
    }
  • 相关阅读:
    [Unity热更新]04.卸载方式
    [Unity热更新]03.加载方式
    [Unity热更新]02.依赖关系
    [Unity热更新]01.打包与加载基础
    [Unity优化]批处理05:UGUI
    [Unity优化]gc02:StringBuilder
    [Unity优化]gc01:字符串常量池
    虚拟机中安装centos系统的详细过程
    零基础学习java------40---------Maven(maven的概念,安装,maven在eclipse中使用),springboot(spring整合springmvc(注解),spring整合mybatis(常见的配置文件)),前端页面(bootstrap软件)
    零基础学习java------39---------json格式交互,Restful(不懂),静态资源映射,SSM整合(ssm整合思想,application.xml文件详解(声明式事务管理),)
  • 原文地址:https://www.cnblogs.com/BobHuang/p/9555366.html
Copyright © 2011-2022 走看看