QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#397623#5438. Half MixedslenbolWA 0ms3552kbC++141.5kb2024-04-24 15:09:542024-04-24 15:09:54

Judging History

你现在查看的是最新测评结果

  • [2024-04-24 15:09:54]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3552kb
  • [2024-04-24 15:09:54]
  • 提交

answer

#include<bits/stdc++.h>
#define ll long long
using namespace std;
template <typename T> inline void read(T &x)
{
	x=0;T f=1;char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-')f=-1;
	for(;isdigit(c);c=getchar()) x=(x<<1)+(x<<3)+(c^48);
	x*=f;
}
template <typename T,typename ...Args>void read(T &x,Args&...args){read(x),read(args...);}
template <typename T> void print(T x)
{
	if(x<0) x=-x,putchar('-');
	if(x>9) print(x/10);
	putchar(x%10+48);
}
template <typename T> void print(T x,char c){print(x); putchar(c);}
template<typename T>inline void output(T x){print(x,' ');}
template<typename T,typename ...Arg>inline void output(T x,Arg ...arg){output(x);output(arg...);}
const int N=1000007;
int T,n,m; ll vn,vm;
vector<int>solve(int n)
{
	vector<int>res;
	int X=n; ll Y=(ll)n*(n+1)/4-X;
	for(int i=n;i>=2;i--)
	{
		int x=i; ll y=(ll)i*(i+1)/2-x;
		if(Y>=y) Y-=y,X-=x,res.push_back(x);
	}
	while(X) X--,res.push_back(1);
	return res;
}
void solve()
{
	read(n,m);
	vn=(ll)n*(n+1)/2; vm=(ll)m*(m+1)/2;
	if(vn&1&&vm&1) return puts("No"),void();
	puts("Yes");
	if(!(vn&1))
	{
		auto res=solve(n);
		int lst=1,col=48;
		for(auto x:res)
		{
			for(int i=lst;i<lst+x;i++,puts(""))
				for(int j=1;j<=m;j++) putchar(col);
			lst+=x; col^=1;
		}
	}
	else
	{
		auto res=solve(m);
		for(int i=1;i<=n;i++,puts(""))
		{
			int lst=1,col=48;
			for(auto x:res)
			{
				for(int i=lst;i<lst+x;i++)
					putchar(col);
				col^=1;
			}
		}
	}

}
int main()
{
	read(T);
	while(T--) solve();
	return 0;
}

详细

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3552kb

input:

2
2 3
1 1

output:

Yes
010
010
No

result:

wrong output format Expected integer, but "010" found (test case 1)