Guys My code is running correct on the compiler but when I submit , it shows error.
Please can someone tell me what is wrong . Here is the link and code ----------
/*
*
- AUTHOR : Ashish Gururani *
- Language: C++14 *
- Purpose: - *
- IDE used: Visual Studio Code. *
Comments will be included in practice problems if it helps ^^
*/
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define rep(i, n, k) for (ll i = 0; i < n; i += k)
#define rrep(i, n, k) for (ll i = n; i >= 0; i -= k)
#define rep1(i, n, k) for (ll i = 1; i < n; i += k)
#define vi vector
#define vl vector
#define vs vector
#define vvi vector
#define vvl vector
#define vvs vector
#define mem(a, b) memset(a, b, sizeof(a))
#define fast
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL)
#define pb emplace_back
#define mp make_pair
#define fi first
#define se second
#define nline “\n”
#define tc(t)
long long t;
cin >> t;
while (t–)
#define all(x) (x).begin(), (x).end()
#define dbg(x) cout << #x << " = " << x << endl
#define inf 1e6 + 5
#define mod ll(1e9 + 7)
using namespace std;
template
void print_array(const T &arr, char c = ’ ')
{
for (auto x : arr)
{
cout << x << c;
}
cout << endl;
}
template
void input_array(vector &arr)
{
for (ll i = 0; i < arr.size(); i++)
{
cin >> arr[i];
}
}
vvl adj;
vl vis;
int main()
{
#ifndef ONLINE_JUDGE
freopen(“input.txt”, “r”, stdin);
freopen(“error.txt”, “w”, stderr);
freopen(“output.txt”, “w”, stdout);
#endif
fast;
ll a, b, c, d, e, f, m, n, p, q;
string s, r;
tc(t)
{
cin >> n;
vl A, B;
bool flg = 1;
for (ll i = 1; i < n + 1; i++)
{
if (flg)
{
A.pb(i);
i++;
B.pb(i);
flg = 0;
}else{
B.pb(i);
i++;
A.pb(i);
flg=1;
}
}
// print_array(A);
// print_array(B);
ll sum= accumulate(all(A),0);
ll sumb=accumulate(all(B), 0);
// dbg(sum);
if((n*(n+1))/2==2*sum&&sum==sumb &&(n*(n+1))/2==2*sumb){
cout<<"YES"<<endl;
swap(A[A.size() -1], A[0] );
print_array(A);
print_array(B);
}else {
cout<<"NO"<<endl;
}
}
return 0;
}