답안 #341367

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
341367 2020-12-29T14:56:26 Z ogibogi2004 Red-blue table (IZhO19_stones) C++14
17 / 100
94 ms 1536 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 res1=m+(m*(n-n1))/m1;
	int res2=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]<m1)v.push_back(i);
			}
			for(int i=1;i<=n&&v.size()<n-n1;i++)
			{
				v.push_back(i);
			}
			for(int i=0;i<v.size()&&i<n-n1;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]<n1)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++)
		{
			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 of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   33 |    for(int i=1;i<=n&&v.size()<n-n1;i++)
      |                      ~~~~~~~~^~~~~
stones.cpp:37:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |    for(int i=0;i<v.size()&&i<n-n1;i++)
      |                ~^~~~~~~~~
stones.cpp:60:30: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   60 |    for(int j=1;j<=m&&v.size()<m-m1;j++)
      |                      ~~~~~~~~^~~~~
stones.cpp:64:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   64 |    for(int j=0;j<v.size()&&j<m-m1;j++)
      |                ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 11 ms 364 KB in the table A+B is not equal to 6
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Incorrect 11 ms 364 KB in the table A+B is not equal to 6
# 결과 실행 시간 메모리 Grader output
1 Incorrect 94 ms 1536 KB in the table A+B is not equal to 116
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 74 ms 1516 KB in the table A+B is not equal to 44
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Incorrect 11 ms 364 KB in the table A+B is not equal to 6