답안 #172671

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
172671 2020-01-02T10:31:22 Z ogibogi2004 Red-blue table (IZhO19_stones) C++14
0 / 100
103 ms 1528 KB
#include<bits/stdc++.h>
using namespace std;
int br[1024];
char table[1024][1024];
void solve()
{
	int n,m,n1,m1;
	cin>>n>>m;
	n1=n/2+1;
	m1=m/2+1;
	int res2=m+m*(n-n1)/m1;
	int res1=n+n*(m-m1)/n1;
	memset(br,0,sizeof(br));
	vector<int>v;
	
	if(res1>res2)
	{
		//cout<<"*\n";
		for(int i=1;i<=n;i++)
		{
			for(int j=1;j<=m;j++)
			{
				table[i][j]='-';
			}
		}
		for(int j=1;j<=m;j++)
		{
			v.clear();
			for(int i=1;i<=n;i++)
			{
				if(br[i]<n1)v.push_back(i);
			}
			for(int i=1;i<=n&&v.size()<=m-m1;i++)
			{
				v.push_back(i);
			}
			for(int i=0;i<v.size();i++)
			{
				table[v[i]][j]='+';
				br[v[i]]++;
			}
		}
	}
	else
	{
		for(int i=1;i<=n;i++)
		{
			for(int j=1;j<=m;j++)
			{
				table[i][j]='+';
			}
		}
		for(int i=1;i<=n;i++)
		{
			v.clear();
			for(int j=1;j<=m;j++)
			{
				if(br[j]<m1)v.push_back(j);
			}
			for(int j=1;j<=m&&v.size()<=m-m1;j++)
			{
				v.push_back(j);
			}
			for(int j=0;j<v.size()&&j<=m-m1;j++)
			{
				table[i][v[j]]='-';
				br[v[j]]++;
			}
		}
	}
	cout<<max(res1,res2)<<endl;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			if(table[i][j]=='-')table[i][j]='+';
			else table[i][j]='-';
			cout<<table[i][j];
		}
		cout<<endl;
	}
}
int main()
{
	int t;
	cin>>t;
	while(t--)solve();
return 0;
}

Compilation message

stones.cpp: In function 'void solve()':
stones.cpp:33:30: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for(int i=1;i<=n&&v.size()<=m-m1;i++)
                      ~~~~~~~~^~~~~~
stones.cpp:37:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for(int i=0;i<v.size();i++)
                ~^~~~~~~~~
stones.cpp:60:30: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for(int j=1;j<=m&&v.size()<=m-m1;j++)
                      ~~~~~~~~^~~~~~
stones.cpp:64:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for(int j=0;j<v.size()&&j<=m-m1;j++)
                ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 376 KB in the table A+B is not equal to 3
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 15 ms 376 KB in the table A+B is not equal to 46
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 376 KB in the table A+B is not equal to 3
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 103 ms 1508 KB in the table A+B is not equal to 116
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 75 ms 1528 KB in the table A+B is not equal to 44
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 376 KB in the table A+B is not equal to 3
2 Halted 0 ms 0 KB -