Why do I get Wrong Answer?

,

https://discuss.codechef.com/questions/7640/why-do-i-get-wrong-answer/64059
there are a lot more cases which are hidden and sample cases are not the only ones otherwise there would be no point in submitting you could check them yourself right !!

  1. Nick is now a well settled person. Impressed by the coding skills of Nick, N girls wish to marry him. Nick will consider marriage proposals of only those girls who have some special qualities. Qualities are represented by positive non-zero integers.
    Nick has a list of M qualities which he wants in a girl. He can also consider those girls who have some extra qualities, provided they have at least all those qualities which Nick wants.
    Find how many girls’ proposal will Nick consider.
    Input:
    First line contains the integer M, denoting the number of qualities which Nick wants.
    Next line contains M single space separated distinct integers.
    Third line contains an integer N, denoting the number of girls.
    Next follow N lines, ith line contains few single-space separated distinct integers, denoting the qualities of the ith girl.
    Output:
    Print the number of girls, whose proposals will be considered by Nick.
    Constraints:
    1 ≤ M ≤ 100
    1 ≤ N ≤ 9 x 103
    1 ≤ Maximum no. of qualities possessed by girls ≤ 1000.
    Qualities are positive non-zero integers such that 1 ≤ Quality ≤ 104
    Subtask 1: ( 30 points )
    1 ≤ M ≤ 10
    1 ≤ N ≤ 100
    1 ≤ Maximum no. of qualities possessed by girls ≤ 100.
    Qualities are positive non-zero integers such that 1 ≤ Quality ≤ 1000
    Subtask 2: ( 70 points )
    Original constraints
    Sample Input:
    5
    1 2 3 4 5
    3
    1 2 3 4 5 6
    1 2 3 4 5
    1 2 3 4
    Sample Output:
    2

can any one ans me?

  1. Nick is now a well settled person. Impressed by the coding skills of Nick, N girls wish to marry him. Nick will consider marriage proposals of only those girls who have some special qualities. Qualities are represented by positive non-zero integers.
    Nick has a list of M qualities which he wants in a girl. He can also consider those girls who have some extra qualities, provided they have at least all those qualities which Nick wants.
    Find how many girls’ proposal will Nick consider.
    Input:
    First line contains the integer M, denoting the number of qualities which Nick wants.
    Next line contains M single space separated distinct integers.
    Third line contains an integer N, denoting the number of girls.
    Next follow N lines, ith line contains few single-space separated distinct integers, denoting the qualities of the ith girl.
    Output:
    Print the number of girls, whose proposals will be considered by Nick.
    Constraints:
    1 ≤ M ≤ 100
    1 ≤ N ≤ 9 x 103
    1 ≤ Maximum no. of qualities possessed by girls ≤ 1000.
    Qualities are positive non-zero integers such that 1 ≤ Quality ≤ 104
    Subtask 1: ( 30 points )
    1 ≤ M ≤ 10
    1 ≤ N ≤ 100
    1 ≤ Maximum no. of qualities possessed by girls ≤ 100.
    Qualities are positive non-zero integers such that 1 ≤ Quality ≤ 1000
    Subtask 2: ( 70 points )
    Original constraints
    Sample Input:
    5
    1 2 3 4 5
    3
    1 2 3 4 5 6
    1 2 3 4 5
    1 2 3 4
    Sample Output:
    2

can any one ans me?

  1. Nick is now a well settled person. Impressed by the coding skills of Nick, N girls wish to marry him. Nick will consider marriage proposals of only those girls who have some special qualities. Qualities are represented by positive non-zero integers.
    Nick has a list of M qualities which he wants in a girl. He can also consider those girls who have some extra qualities, provided they have at least all those qualities which Nick wants.
    Find how many girls’ proposal will Nick consider.
    Input:
    First line contains the integer M, denoting the number of qualities which Nick wants.
    Next line contains M single space separated distinct integers.
    Third line contains an integer N, denoting the number of girls.
    Next follow N lines, ith line contains few single-space separated distinct integers, denoting the qualities of the ith girl.
    Output:
    Print the number of girls, whose proposals will be considered by Nick.
    Constraints:
    1 ≤ M ≤ 100
    1 ≤ N ≤ 9 x 103
    1 ≤ Maximum no. of qualities possessed by girls ≤ 1000.
    Qualities are positive non-zero integers such that 1 ≤ Quality ≤ 104
    Subtask 1: ( 30 points )
    1 ≤ M ≤ 10
    1 ≤ N ≤ 100
    1 ≤ Maximum no. of qualities possessed by girls ≤ 100.
    Qualities are positive non-zero integers such that 1 ≤ Quality ≤ 1000
    Subtask 2: ( 70 points )
    Original constraints
    Sample Input:
    5
    1 2 3 4 5
    3
    1 2 3 4 5 6
    1 2 3 4 5
    1 2 3 4
    Sample Output:
    2

can any one ans me?

This is my code CodeChef: Practical coding for everyone

for MARCHA1 Problem - CodeChef this.

In CodeChef IDE My code run properly and give the right output for the given inputs.
but at the submission time it show me WRONG ANSWER!!! message.

What is problem with my Code???

import java.util.Scanner;
public class A1 {
public static void main(String args[]){
Scanner input=new Scanner(System.in);
int t=input.nextInt();
int a[]=new int[t];
for(int i=0;i<t;i++) {
System.out.println("");
int n=input.nextInt();
int factorial=1;
for(int x=1;x<=n;x++){
factorial=factorial*x;
}
a[i]=factorial;
}

for(int d=0;d<t;d++){
System.out.println(a[d]);
}
}
}

For Practice Survive
import java.util.;
import java.lang.
;
import java.io.;
/
Name of the class has to be “Main” only if the class is public. /
class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
Scanner sx=new Scanner(System.in);
int t=sx.nextInt();
if(t<=100) {
for(int i=0;i<t;i++)
{
int n=sx.nextInt();
int k=sx.nextInt();
int s=sx.nextInt();
if(n<=100 && k<=100 && s<=1000)
{
int res=(n
(s-(s/7)))-ks;
if(res<0)
{
System.out.println(“-1”);
}
else if(res==0)
{
System.out.println(s-(s/7));
}else{System.out.println(1+((k
s)/n));}}}}sx.close();}}

#include
using namespace std;
int main()
{
long int n,m,diff;
cin>>n>>m;
diff=n-m;
cout<<endl;

if(diff>=0)
{

if((diff%2)==0)
{
	diff+=1;
}
else
{
	diff-=1;
}
cout<<diff;

}
else
return 0;
}
whats the prblem in above code???

#include <bits/stdc++.h>
using namespace std;

bool mem[122][1000002];
bool gop = false;
int N;
vector ps;
vector ans;
void dfs(int dx, int sam, int bef, string ss) {
if (sam + bef > N || gop) { return; }
if (sam + bef == N && dx>=ss.length()) {
for (auto v : ps) {
ans.push_back(v);
}
gop = true;
return;
}
if (mem[dx][sam + bef] != 0) {
return;
}
if (sam + bef > 0) {
mem[dx][bef + sam] = 1;
}
if (dx >= ss.length()) { return; }
int nev = 0;
for (int i = dx;i < dx + 7 && i<ss.length();i++) {
nev = nev * (int)10 + (int)(ss[i] - ‘0’);
if (nev > N) { return; }
ps.push_back(dx);
dfs(i + 1, sam + bef, nev, ss);
ps.pop_back();
}
}

int main() {
int test;cin >> test;
while (test–) {
gop = false;ps.clear();ans.clear();
memset(mem, false, sizeof mem);
string ss;cin >> ss;
cin >> N;
dfs(0, 0, 0, ss);
string rol;rol.resize(ans.size() - 1 + ss.length());
reverse(ans.begin(), ans.end());
ans.pop_back();
reverse(ans.begin(), ans.end());
for (int z = 0, j = 0, k = 0;z < rol.length();z++) {
if (j < ss.length() && (k >= ans.size() || j < ans[k])) {
rol[z] = ss[j];
j++;
}
else if (k < ans.size()) {
rol[z] = ‘+’;
k++;
}
}
cout << rol << endl;
}
return 0;
}

Hey please add new line in your code in output section then you will surely get AC

1 Like

Because You have missed “\n” after cout<<i statement.

1 Like

why is it showing wrong answer?

if it’s from a live contest u mustn’t share it even if it’s partial you may be disqualified for this

HOPE IT WAS USEFUL…

Plz give a link to the Q you are solving.

Sample inputs are just public test cases but your code need to pass all the public as well as private test cases.you can follow this link for more info…https://www.quora.com/What-is-the-advice-you-would-give-a-beginner-whose-code-passes-all-public-test-cases-but-fails-around-40-50-of-test-cases

1 Like

You are printing nothing dear. The Q asks you to print the number entered on a new line UNTIL 42 is entered. Add a print statement after break statement and it will be fine. :slight_smile:

i have some more doubts but i cant ask question due to insufficient karma points so please upvote me

i have some more doubts but i cant ask question due to insufficient karma points so please upvote me

there are a lot more cases which are hidden and sample cases are not the only ones otherwise there would be no point in submitting you could check them yourself right !!