ICPC Is Coming In Hot!

Tanmoy is an ACM ICPC contestant. During practice he came across a problem named ‘OWLLEN’. He has ha…

Click here to read the complete problem statement.


If you need help solving this problem, mention your approach and ask specific questions. Please avoid sharing your code and asking the Community to figure out “what’s wrong”.

1 Like

There’s a problem with the test cases. I got AC with this code,

    String ab = inp.next();
    char c [] = ab.toCharArray();
    int temp=0,storage;
    storage =0;
    for(int i=0;i<c.length ;i++)
    {
        int count =0;
        for(int j=0;j<c.length ;j++)
        {
            if(c[i]==c[j])
            {
                count++ ;
            }
        }
        if(count>storage)
        {
            storage =count;
            temp =c[i]-'0';
        }

    }
    System.out.println(temp);

It’s a number not a string.If i input 1213 in your code then 1213 will only store in index 0.

what is the test case 4?My code isn’t getting past test case 4.But i have checked my code for every posssible value it’s properly working.What’s the problem here please someone tell me.

1 Like

my code is not working for testcase 3 what is the problem?

#include<bits/stdc++.h>

using namespace std;

int main() {
	string s;
	cin >> s;
	int a[10];
    a[0] = count(s.begin(),s.end(),'0');
    a[1] = count(s.begin(),s.end(),'1');
	a[2] = count(s.begin(),s.end(),'2');
	a[3] = count(s.begin(),s.end(),'3');
	a[4] = count(s.begin(),s.end(),'4');
	a[5] = count(s.begin(),s.end(),'5');
	a[6] = count(s.begin(),s.end(),'6');
	a[7] = count(s.begin(),s.end(),'7');
	a[8] = count(s.begin(),s.end(),'8');
	a[9] = count(s.begin(),s.end(),'9');
	int max = *max_element(a,a+9);
	cout << a[max] << endl;
	return 0;
}

Plz check the last statement . Will your code work properly ?

#include
#include

using namespace std;

int main() {
int N = 0, count[10], num;

cin>>N;

for(int i = 0; i < 10; i++ ){
    count[i] = 0;
}

while(N != 0){
    num = N%10;
    count[num]++;
    N = N/10;
}

int max = count[0], max_digit = 0, max_digit_1 = 0;
for(int i = 0; i <= 9; i++){
    if(max == count[i] && max != 0){
        max_digit_1 = i;
    }
    if(max < count[i]){
        max = count[i];
        max_digit = i;
    }
}

if(max_digit_1 != 0){
    (max_digit < max_digit_1) ? cout<<max_digit<<endl : cout<<max_digit_1<<endl;
}else {
    cout<<max_digit<<endl;
}

return 0;

}

3rd case got wrong answer.

In my MinGW compiler I got right answers.But in this website’s compiler giving me wrong answers.But why?

#include<stdio.h>

int main()

{

char num[10];

int i,a,count[10]={0},len,max=0;

scanf("%s",num);

for(i;num[i];i++){}

len = i-1;

for(i;i>=0;i--){

    a = num[i] - '0';

    switch(a){

        case 0:

            count[0]++;

            break;

        case 1:

            count[1]++;

            break;

        case 2:

            count[2]++;

            break;

        case 3:

            count[3]++;

            break;

        case 4:

            count[4]++;

            break;

        case 5:

            count[5]++;

            break;

        case 6:

            count[6]++;

            break;

        case 7:

            count[7]++;

            break;

        case 8:

            count[8]++;

            break;

        case 9:

            count[9]++;

            break;

        default:

            break;

    }

}

for(len;len >= 0;len--){

    if(max <= count[len]){

        max = count[len];

        i = len;

    }

}

printf("%d",i);

return 0;

}

It should work. But why is it giving the wrong answer while getting input from test case 4?

#include <stdio.h>

int main()
{
    int num, count, result, digit[10];
    scanf("%d", &num);

    for (int i = 0; i < 10; i++) {
        digit[i] = 0;
    }
    while (num != 0) {
        digit[num % 10]++;
        num /= 10;
    }
    count = 0;
    for (int i = 0; i < 10; i++) {
        if (digit[i] > count) {
            count = digit[i];
            result = i;
        }
    }

    printf("%d\n", result);

    return 0;
}```

@integer The statement has been updated. Please check the problem statement again… especially the input specification. Previously the contraint was formatted incorrectly.

Sorry for the inconvenience.

#include <stdio.h>


int main(void)
{
     int c[10] = {0,0,0,0,0,0,0,0,0,0}, x = 0, max = 0, ans = 0;
     long int num;
     scanf("%li", &num);

     while(num > 0)
     {
         c[num % 10]++;
         num /= 10;
         x++;
     }

     for (int i = 0; i < 10; i++)
     {
          if (max < c[i])
          {
               max = c[i];
               ans = i;
          }
     }

     printf("%d", ans);

     return 0;
}

why this code not passing test:4 and why there is no debugging icon?

N can be a very large number. See the input section of the problem description.

A number that large cannot be read into long long int. Try to think of another way to read a large number than can have thousands of digits.

Why this code is not producing the correct output for 2nd test case?

num = input('')

numlist = {
    
}

for i in num:
    if numlist.get(i) == None:
        numlist.update({f"{i}": "1"})
    else:
        count = numlist.get(i)
        count = int(count)
        numlist.update({f"{i}": f"{count + 1}"})

maxValue = max(numlist.values())


resultList = []

for x in numlist:
    if numlist.get(x) == maxValue:
        resultList.append(x)

print(min(resultList))