20 💡 Arrays-Wave print Column Wise (correct code still getting error)

I have solved this problem and getting correct output even in codeblock IDLE. But while submitting code in challenge i am getting this error.
Here is the IDLE code https://ide.codingblocks.com/s/147773

" terminate called after throwing an instance of ‘std::bad_array_new_length’
what(): std::bad_array_new_length "

#include<bits/stdc++.h>

using namespace std;

void wave(int** a,int row,int col)
{
int flag=0; //if flag=0 go down, if flag =1 go up.
int icol=0;

while(icol<col)
{
	if(flag==0)
	{
		for (int i = 0; i < row; ++i)
		{
			cout<<a[i][icol]<<", ";
		}++icol;
		flag=1;
	}
	else if(flag==1)
	{
		for (int i = row-1; i >=0; --i)
		{
			cout<<a[i][icol]<<", ";
		} ++icol;
		flag=0;
	}
} cout<<"END";

}

int main()
{
int row_count,col_count;
cin>>row_count>>col_count;
//generate dynamic 2d array,
//dont forget to delete after work. delete []A;
int** A=new int*[row_count];
for (int i = 0; i < row_count; ++i)
{
A[i]=new int[col_count];
} // A[row_count][col_count];

// insert elements in 2D array.
for (int i = 0; i < row_count; ++i)
{
	for (int j = 0; j < col_count; ++j)
	{
		cin>>A[i][j];
	}
}

wave(A,row_count,col_count);
delete []A;

return 0;

}

hi rohit
it is working fine for me and getting 100 points
submit it twice or thrice time may be some backend issue

or if not getting correct then once make the array statically