samedi 28 septembre 2019

Even though my sample output matches with expected output, sample test cases aren't passed

I submitted the code for a competitive programming hiring challenge and even though my sample test cases are same as expected my sample test cases aren't passed, Please help me.

I've already tried using \t , before or after to exactly match the expected output, even though the code may be wrong, at-least sample test cases should be passed

#include<iostream>

int main(){
    int a[2000],z,T,N;

    std::cin >> T;

      while(T--) {

    std::cin >> N;

    for(int i=0;i<N;i++) {
        if(i==0||i==1) {
            a[i] = 1;
            }
        if(i==2) {
            a[i] = a[i-1] + a[i-2];
            z = a[i];
            }
        if(i>2) {
            if(i%2!= 0) {
                a[i] = z;
            }
            else{
                a[i] = a[i-1] + a[i-2];
            }
        }
    }
    for(int i=0;i<N;i++) {
    std:: cout << a[i] << "\t" ;    
    }
    std:: cout << "\n";
    }
     return 0;
     }

Expected and actual results look almost same as mentioned in screenshot, sample test cases should be passed...

enter image description here

Aucun commentaire:

Enregistrer un commentaire