My issue
include <bits/stdc++.h>
using namespace std;
int main() {
// your code goes here
int t;
cin>>t;
while(t–) {
int n;
cin >> n;
if(n/2 % 2 == 0) {
cout << "YES\n";
vector<int>a, b;
a.push_back(1);
int i=2, j=0;
while(i <= n) {
if(j==0 or j==1) {
b.push_back(i);
j++;
}
else {
a.push_back(i);
if(j == 3) j=0;
else j++;
}
i++;
}
for(auto& i : a) {
cout << i << " ";
}
cout << endl;
for(auto& i : b) {
cout << i << " ";
}
cout << endl;
}
else {
cout << "NO\n";
}
}
return 0;
}
// please, help me, why this code is not giving AC.
My code
#include <bits/stdc++.h>
using namespace std;
int main() {
// your code goes here
int t;
cin>>t;
while(t--) {
int n;
cin >> n;
if(n/2 % 2 == 0) {
cout << "YES\n";
vector<int>a, b;
a.push_back(1);
int i=2, j=0;
while(i <= n) {
if(j==0 or j==1) {
b.push_back(i);
j++;
}
else {
a.push_back(i);
if(j == 3) j=0;
else j++;
}
i++;
}
for(auto& i : a) {
cout << i << " ";
}
cout << endl;
for(auto& i : b) {
cout << i << " ";
}
cout << endl;
}
else {
cout << "NO\n";
}
}
return 0;
}
Problem Link: Prefix Sums Practice Coding Problem