답안 #161612

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
161612 2019-11-03T09:59:02 Z MvC Red-blue table (IZhO19_stones) C++11
42 / 100
67 ms 3448 KB
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
#include <bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define mkp make_pair
#define in insert
#define er erase
#define fd find
#define fr first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll llinf=(1LL<<62);
const int inf=(1<<30);
const int nmax=1e3+50;
const int mod=1e9+7;
int ts,i,j,t,cic[nmax],nr[nmax],tr,cur,rs,n,m;
vector<int>vc[nmax];
char c[nmax][nmax];
int main()
{
	//freopen("sol.in","r",stdin);
	//freopen("sol.out","w",stdout);
	//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
	cin>>ts;
	while(ts--)
	{
		cin>>n>>m;
		rs=max(n,m);
		for(i=1;i<=n;i++)for(j=1;j<=m;j++)c[i][j]='-';
		for(i=1;i<=m;i++)nr[i]=cic[i]=0;
		for(i=1;i<=n;i++)
		{
			for(j=0;j<=n;j++)vc[j].clear();
			for(j=1;j<=m;j++)
			{
				if(nr[j]>n-n/2-1)cic[j]=1;
				if(!cic[j])vc[nr[j]].pb(j);
			}
			tr=m/2+1;
			for(j=1;j<=m;j++)
			{
				if(!tr)break;
				if(cic[j])
				{
					nr[j]++;
					tr--;
					c[i][j]='+';
				}
			}
			for(j=0;j<=n;j++)
			{
				if(!tr)break;
				for(t=0;t<(int)vc[j].size();t++)
				{
					if(!tr)break;
					c[i][vc[j][t]]='+';
					nr[vc[j][t]]++;
					tr--;
				}
			}
			cur=0;
			for(j=1;j<=m;j++)if(nr[j]<=n-n/2-1)cur++;
			rs=max(rs,cur+i);
		}
		if(rs==n)for(i=1;i<=n;i++)for(j=1;j<=m;j++)c[i][j]='+';
		if(rs==m)for(i=1;i<=n;i++)for(j=1;j<=m;j++)c[i][j]='-';
		if(rs!=max(n,m))
		{
			for(i=1;i<=n;i++)for(j=1;j<=m;j++)c[i][j]='-';
			for(i=1;i<=m;i++)nr[i]=cic[i]=0;
			for(i=1;i<=n;i++)
			{
				for(j=0;j<=n;j++)vc[j].clear();
				for(j=1;j<=m;j++)
				{
					if(nr[j]>n-n/2-1)cic[j]=1;
					if(!cic[j])vc[nr[j]].pb(j);
				}
				tr=m/2+1;
				for(j=1;j<=m;j++)
				{
					if(!tr)break;
					if(cic[j])
					{
						nr[j]++;
						tr--;
						c[i][j]='+';
					}
				}
				for(j=0;j<=n;j++)
				{
					if(!tr)break;
					for(t=0;t<(int)vc[j].size();t++)
					{
						if(!tr)break;
						c[i][vc[j][t]]='+';
						nr[vc[j][t]]++;
						tr--;
					}
				}
				cur=0;
				for(j=1;j<=m;j++)if(nr[j]<=n-n/2-1)cur++;
				if(cur+i==rs)break;
			}
		}
		cout<<rs<<'\n';
		for(i=1;i<=n;i++)
		{
			for(j=1;j<=m;j++)cout<<c[i][j];
			cout<<'\n';
		}
	}
	return 0;
}

Compilation message

stones.cpp:2:0: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
 #pragma GCC optimization("O3")
 
stones.cpp:3:0: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
 #pragma GCC optimization("unroll-loops")
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 4 ms 376 KB Output is correct
4 Incorrect 5 ms 504 KB Wrong answer in test 37 5: 39 < 40
# 결과 실행 시간 메모리 Grader output
1 Incorrect 67 ms 1656 KB Wrong answer in test 97 21: 112 < 116
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 64 ms 1656 KB Output is correct
2 Correct 55 ms 3448 KB Output is correct
3 Correct 49 ms 2680 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 4 ms 376 KB Output is correct
4 Incorrect 5 ms 504 KB Wrong answer in test 37 5: 39 < 40