QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#664170#5438. Half MixedYurilyWA 155ms3924kbC++201.7kb2024-10-21 19:27:312024-10-21 19:27:32

Judging History

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

  • [2024-10-21 19:27:32]
  • 评测
  • 测评结果:WA
  • 用时:155ms
  • 内存:3924kb
  • [2024-10-21 19:27:31]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
using namespace std;
const int MAX=1e6+5;
int n,m;
vector<int> ans[MAX];
void solve(){
	cin>>n>>m;	
	int k=(1+n)*n/2*(1+m)*m/2;
	for(int i=1;i<=n;++i){
		ans[i].clear();
		for(int j=1;j<=m+1;++j)
			ans[i].push_back(0);
	}
	if(k&1){
		printf("No\n");
		return;
	} 
	if(m%4==0||(1+m)%4==0){
		bool flag=0;
		int cur=0,now=0,len=0,k=(1+m)*m/4;
		while(cur<m){
			cur++,len++;
			ans[1][cur]=now;
		//	cout<<cur<<endl;
			if((1+len)*len/2+m-cur>k){
			//	cout<<cur<<endl;
				cur--;
				len--;
				if(len>=1){
					k-=(1+len)*len/2;
					len=0;
					now^=1;
				}
				else
					break;
			}			
			if(k==(1+len)*len/2&&cur==m){
				flag=1;
				break;
			}
			if(k==0)
				break;
		}
		if(flag){
			printf("Yes\n");
			for(int i=2;i<=n;++i){
				for(int j=1;j<=m;++j)
					ans[i][j]=ans[i-1][j];
			}
			for(int i=1;i<=n;++i){
				for(int j=1;j<=m;++j)
					printf("%d ",ans[i][j]);
				printf("\n");
			}
			return;
		}
	}
	if(n%4==0||(1+n)%4==0){
		bool flag=0;
		int cur=0,now=0,len=0,k=(1+n)*n/2;
		while(cur<n){
			cur++,len++;
			ans[cur][1]=now;
			if((1+len)*len/2+n-cur>k){
				cur--;
				len--;
				if(len>=1){
					k-=(1+len)*len/2;
					len=0;
					now^=1;
				}
				else
					break;
			}			
			if(k==(1+len)*len/2&&cur==n){
				flag=1;
				break;
			}
			if(k==0)
				break;
		}
		if(flag){
			printf("Yes\n");
			for(int j=2;j<=m;++j){
				for(int i=1;i<=n;++i)
					ans[i][j]=ans[i][j-1];
			}
			for(int i=1;i<=n;++i){
				for(int j=1;j<=m;++j)
					printf("%d ",ans[i][j]);
				printf("\n");
			}
			return; 
		}
	}
	printf("No\n");
}
signed main(){
	int T;
	cin>>T;
	while(T--){
		solve();
	}
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 3792kb

input:

2
2 3
1 1

output:

Yes
0 1 0 
0 1 0 
No

result:

ok OK, Accepted. (2 test cases)

Test #2:

score: -100
Wrong Answer
time: 155ms
memory: 3924kb

input:

5382
1 1
1 2
2 1
1 3
2 2
3 1
1 4
2 3
3 2
4 1
1 5
2 4
3 3
4 2
5 1
1 6
2 5
3 4
4 3
5 2
6 1
1 7
2 6
3 5
4 4
5 3
6 2
7 1
1 8
2 7
3 6
4 5
5 4
6 3
7 2
8 1
1 9
2 8
3 7
4 6
5 5
6 4
7 3
8 2
9 1
1 10
2 9
3 8
4 7
5 6
6 5
7 4
8 3
9 2
10 1
1 11
2 10
3 9
4 8
5 7
6 6
7 5
8 4
9 3
10 2
11 1
1 12
2 11
3 10
4 9
5 8
6 ...

output:

No
No
No
Yes
0 1 0 
No
Yes
0 
0 
0 
Yes
0 0 1 0 
Yes
0 1 0 
0 1 0 
Yes
0 0 
0 0 
0 0 
Yes
0 
0 
0 
0 
No
Yes
0 0 1 0 
0 0 1 0 
Yes
0 1 0 
0 1 0 
0 1 0 
Yes
0 0 
0 0 
0 0 
0 0 
No
No
No
Yes
0 0 1 0 
0 0 1 0 
0 0 1 0 
Yes
0 1 0 
0 1 0 
0 1 0 
0 1 0 
No
No
Yes
0 0 0 0 1 1 0 
No
Yes
0 0 0 0 0 
0 0 0 0 0...

result:

wrong answer 0 Mixed Submatrices Found, but 3 Expected (test case 6)