Getting WA on CF

Problem link: Question
Mysolution: Solution

Error on input case:
3
1 2
2 2 3
Output

I become the guy.

Answer

Oh, my keyboard!

I think the Tester solution is wrong here. As my output is correct.

    #include <bits/stdc++.h>
    using namespace std;
    typedef long long int ll;
    #define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
     
     
    int main()
    {
        fast
        int t;
        cin>>t;
        int arr[t+1];
        for(int i=0;i<=t;i++){
            arr[i]=0;
        }
        int x;
        while(cin>>x){
           arr[x]++;
        }
        // for(int i=1;i<t;i++){
        //     cout<<arr[i];
        // }
        bool res=true;
        for (int i = 1;i<=t; i++)
        {
            if(arr[i]==0){
                cout<<"Oh, my keyboard!"<<endl;
                res=false;
                break;
            }
        }
        if(res){
            cout<<"I become the guy."<<endl;
        }
        // while(t--)
        // {
           
        // } 
        return 0;
    }

implement using set in c++. see below My Code in C++;

#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false);cin.tie(0);
#define lli long long int
#define vi vector<lli>
#define pb push_back
#include<string>
#define mp map<string,lli>
#define test lli t;cin>>t;while(t--)
using namespace std;
int main()
{
    lli n,p,q;
    cin>>n;
    cin>>p;
    vi arr(p);
    for(auto &it:arr)
        cin>>it;
    cin>>q;
    vi brr(q);
    for(auto &it1:brr)
        cin>>it1;
    set<lli>a(arr.begin(),arr.end());
    for(lli i=0;i<q;i++)
        a.insert(brr[i]);
    if(a.size()==n)
        cout<<"I become the guy.\n";
    else
        cout<<"Oh, my keyboard!\n";
}

1 Like

I think the issue on your code is with the while(cin>>x) part.
You do not have to increment arr[x] every time. The input format clearly says the first number in the second line represents the number of numbers following.
Change suggested:

    while(x--){
      int z;cin>>z;
      arr[z]++;
    }

    int y;cin>>y;
    while(y--){
      int z;cin>>z;
      arr[z]++;
    }

Link to submission after making this change:

Hope I helped!

1 Like

Yeah, I misread it. Got it Accepted

1 Like

thank you, I got it.

I see that you post both the question link and the submission link and even describe your issue in your topics. Like in this topic too. Great to see such a responsible forum member!
I see that you even tried to format your code for ease of all, but it didn’t work out.

It’s because you have to use back ticks ``` instead of '''. You can see how to format your code here!

1 Like

@manvi_03 Yeah!,Even I was confused why the code formatting isn’t working. Thank you for mentioning the error.

1 Like