Ttuple only 90

https://www.codechef.com/JUNE20B/problems/TTUPLE
in ttuple from current long contest I literally tried billion over random test cases but failed to find the edge case for sub-task 1.
can @admin or anyone help me to find the case.

https://www.codechef.com/viewsolution/34386910

I was getting 90 points because I missed the multplication cases.

@scorchingeagle
Your solution misjudges results of some case as 2 but actual answer is 3.
For example:
T1:
1
-10 -10 -9
9 -7 9
Your Output = 2, Actual answer = 3

T2:
1
-10 -10 -9
9 -7 9
Your Output = 2, Actual answer = 3

Now, debug your code with these test cases.

1 Like

thank You. :black_heart:

1 Like

Was it an observation or did you stress test it? If you stress tested it can you share how?

1 Like

Actually while testing my code, I made a few if/else conditions and hence creating some test cases(around 60). So, I just ran his code against those test cases, and, listed the ones that failed.

Any other cases like this? Will be helpfull if u share 'em. :slight_smile:

1 Like

Oh okay, so here are is the list of all the test cases that I tried.
Hope that helps! :innocent:

Pastebin Link : 50+ Test Cases for TTUPLE(100pts)

How can someone get even 90 points if they are not being able to solve for all cases ?like multiplication cases?

Actually, CodeChef has weak test cases for 90 and some strong ones for 10, because there is no way one can get 90 and not the 10.

1 Like

yeah even I thought the same,I thought may be after the contest is over many 90s would fail the 80% system test cases

I had the same thing 0pts + 90pts. Instead of stressing myself to find the missing cases, just wrote a brute force for cases with small constraints xD

Not the right thing to do but is surely much easier

nice lol

my code’s output is 3 for your test case, but can you test my piece of code please?
it also have the problem of 90.

#include <iostream>
using namespace std;

/*
#include <fstream>
std::ifstream cin("input.txt");
std::ofstream cout("co.txt");

*/
#include <set>
std::set<int>::iterator it;

int gOP(int[],int[]);
void solve();

int main(){
int t;cin>>t;
while(t--)solve();
return 0;
}

void solve(){
bool f = true;
int x[3],y[3],res;
cin>>x[0]>>x[1]>>x[2]>>y[0]>>y[1]>>y[2];
for(int i =0;i<3;i++){
    if(x[i]!=y[i])f = false;
}   //case for zero
if(f){cout<<0<<'\n';return;}


res=gOP(x,y);                       //simple cases of 1 and 2
if(res<3){cout<<res<<'\n';return;}



//complicated case 2 starts here
int ddx[3],ddy[3],potential_adds[12],potential_muls[6],add_count=0,mul_count=0,ddn=0;
for(int i =0;i<3;i++){
    potential_adds[add_count++]=y[i]-x[i];
    if(x[i] != 0)if((y[i]%x[i])==0)potential_muls[mul_count++]=y[i]/x[i];  //collecting additive and multiplicative differences in potential_adds(potential additions) and potential_muls (potential multiplications)
}


for(int i=0;i<3;i++)
    for(int j =i+1;j<3;j++){
        ddx[ddn]=(x[i]-x[j]);       //collecting interdifference of values of triples ( dd is a random name)
        ddy[ddn++]=(y[i]-y[j]);
    }



for(int i=0;i<3;i++){
    int tx=ddx[i],ty=ddy[i];
    if (tx!=0)if(ty%tx==0){
        potential_muls[mul_count++]=ty/tx;             // collecting ratio of of dds of x and y
        for(int l=0;l<3;l++){
            int a=x[l],b=y[l];
            if ((ty/tx)!=0)if((b%(ty/tx))==0){
                potential_adds[add_count++]=(b/(ty/tx))-a;        // collecting potential + integer in rare case of + *.
            }
        }
    }
}






int tx[3];      //temporary values of x because we are kinda brute forcing all possible operation on x triple   
for(int i =0;i<add_count;i++){
    int pair_ignore_cases[4],pair_count=1;pair_ignore_cases[0]=4;
    for(int k =0;k<3;k++){
        if(potential_adds[i]==x[k]-y[k])continue;
        pair_ignore_cases[pair_count++]=k;                 // collecting values to ignore while choosig sub values of triple to perform first operation.
    }
    if(pair_count==1)for(int k=0;k<3;k++)pair_ignore_cases[pair_count++]=k;
    for(int k =0;k<pair_count;k++){
        for(int j =0;j<3;j++)(j==pair_ignore_cases[k])?tx[j]=x[j]:tx[j]=x[j]+potential_adds[i];
        if(gOP(tx,y)==1){f=true;break;}
    }
    if(f)break;
}
if(f){cout<<'2'<<'\n';return;}



for(int i =0;i<mul_count;i++){            //very similar just for multiplication operation.
    int pair_ignore_cases[4],pair_count=1;pair_ignore_cases[0]=4;
    for(int k =0;k<3;k++){
        if(x[k]!=0)if(y[k]%x[k]==0)if(potential_muls[i]==y[k]/x[k])continue;
        pair_ignore_cases[pair_count++]=k;
    }
    if(pair_count==1)for(int k=0;k<3;k++)pair_ignore_cases[pair_count++]=k;
    for(int k =0;k<pair_count;k++){
        for(int j =0;j<3;j++)(j==pair_ignore_cases[k])?tx[j]=x[j]:tx[j]=x[j]*potential_muls[i];
        if(gOP(tx,y)==1){f=true;break;}
    }
    if(f)break;
}
if(f){cout<<'2'<<'\n';return;}
cout<<'3'<<'\n';return;
}


int gOP(int x[],int y[]){
int X[3],Y[3],r1,r2,index=0,t=0;
std::set<int> add_diff,mul_diff;
for(int i=0;i<3;i++)
    if(x[i]!=y[i]){
        X[index]=x[i];
        Y[index++]=y[i];
    }
for(int i=0;i<index;i++){
    add_diff.insert(Y[i]-X[i]);
    if(X[i] != 0){if((Y[i]%X[i])==0)mul_diff.insert(Y[i]/X[i]);else t++;}
    else t++;
}
r1 = add_diff.size();
r2 = mul_diff.size()+t;
if(r1<r2)return r1;
return r2;
}