답안 #161610

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
161610 2019-11-03T09:53:52 Z MvC Red-blue table (IZhO19_stones) C++11
15 / 100
73 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);
		}
		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 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 4 ms 504 KB in the table A+B is not equal to 50
# 결과 실행 시간 메모리 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 73 ms 1516 KB Wrong answer in test 97 21: 112 < 116
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 64 ms 1576 KB Output is correct
2 Correct 54 ms 3448 KB Output is correct
3 Correct 49 ms 2640 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 376 KB in the table A+B is not equal to 3
2 Halted 0 ms 0 KB -