Why is my output different in codechef IDE but different if I run it offline?

Problem code is: REVMEE
Problem link

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

int main() {
int t;
cin>>t;
int a[t];
while (t–){
for(int i=0; i<=t; i++){
cin>>a[i];
}
for(int i=t; i>=0; i–){
cout<<a[i]<<" ";
}
}

return 0;

}

At run time------
Input: 4
1 3 2 4
O/p: 4 2 3 1

However in codechef IDE the output is coming as 4 2 3 1 2 3 1 3 1 1

Offline the same gives the intended output, also on Repl.com is showing the expected output.