이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
using namespace std;
const int maxN = 8;
int marked[maxN][maxN];
int c[maxN];
int solve(int n, int m)
{
///N > M
for(int i = 0;i < n;i++)
{
for(int j = 0;j < m;j++)
{
marked[i][j] = 0;
}
}
int centerN = n / 2;
int centerM = m / 2 - 1;
for(int col = 0;col <= centerM; col++)
{
for(int row = col * centerN + col; row <= (col + 1) * centerN; row++)
{
if(row >= n)
{
break;
}
marked[row][col] = 1;
}
}
int sum = n;
for(int j = 0;j < m;j++)
{
int num = 0;
for(int i = 0;i < n;i++)
{
if(marked[i][j] == 1)
{
num++;
}
else
{
break;
}
//cout<<marked[i][j]<<" ";
}
//cout<<num<<endl;
//cout<<centerN + 1<<endl;
if(num >= centerN + 1)
{
sum++;
}
//cout<<endl;
}
/*
for(int i = 0;i < n;i++)
{
for(int j = 0;j < m;j++)
{
cout<<marked[i][j]<<" ";
}
cout<<endl;
}
*/
return sum;
}
void test(int n, int m)
{
int sum = 0;
if(n < m)
{
//swap(n, m);
sum = solve(m, n);
}
else
{
sum = solve(n, m);
}
cout<<sum<<endl;
if(n >= m)
{
for(int row = 0;row < n;row++)
{
for(int col = 0;col < m;col++)
{
if(marked[row][col] == 1)
{
cout<<"-";
}
else
{
cout<<"+";
}
}
cout<<endl;
}
}
else
{
//cout<<"2 wow"<<endl;
int total = 0;
for(int row = 0;row < m;row++)
{
for(int col = 0;col < n;col++)
{
total++;
//cout<<row<<" "<<col<<endl;
if(marked[row][col] == 1)
{
cout<<"+";
}
else
{
cout<<"-";
}
if(total % m == 0)
{
cout<<endl;
}
}
}
}
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t;
cin>>t;
for(int i = 0;i < t;i++)
{
int n,m;
cin>>n>>m;
test(n,m);
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |