QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#360061#5438. Half MixedPYD1#WA 2ms11596kbC++141.9kb2024-03-21 10:55:192024-03-21 10:55:19

Judging History

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

  • [2024-03-21 10:55:19]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:11596kb
  • [2024-03-21 10:55:19]
  • 提交

answer

#include <set>
#include <map>
#include <list>
#include <queue>
#include <cmath>
#include <time.h>
#include <random>
#include <bitset>
#include <vector>
#include <cstdio>
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <memory.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <unordered_map>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define mk make_pair
#define fi first
#define se second

inline int read(){
	int t = 0,f = 1;
	register char c = getchar();
	while (c < 48 || c > 57) f = (c == '-') ? -1 : 1,c = getchar();
	while (c >= 48 && c <= 57) t = (t << 1) + (t << 3) + (c ^ 48),c = getchar();
	return f * t;
}

const int N = 1e6 + 10;
int T,n,m;
ll val[N];

vector <int> res;

bool dfs(int n,ll s){
	if (s == 0){
		for (int i = 1;i <= n;i++) res.emplace_back(1);
		return 1;
	}
	if (n == 0) return s == 0;
	ll x = upper_bound(val + 1,val + 1000001,s) - val - 1;
	for (ll p = x;p > 0;p--){
		res.emplace_back(p);
		if (dfs(n - x,s - val[x])) return 1;
		res.pop_back();
	}
	return 0;
}

void init(){
	for (int i = 1;i <= 1000000;i++) val[i] = 1ll * i * (i - 1) / 2;
}

void solve(){
	n = read(),m = read();
	bool f = 0;
	if ((n & 3) == 1 || (n & 3) == 2) swap(n,m),f = 1;
	if ((n & 3) == 1 || (n & 3) == 2) {puts("No");return ;}
	dfs(n,1ll * n * (n - 1) / 4);
	puts("Yes");
	if (f){
		for (int i = 1;i <= m;i++){
			int c = 0;
			for (int p : res){
				for (int j = 1;j <= p;j++) printf("%d ",c);
				c ^= 1;
			}
			puts("");
		}
	}else{
		int c = 0;
		for (int p : res){
			for (int j = 1;j <= p;j++){
				for (int k = 1;k <= m;k++) printf("%d ",c);puts("");
			}
			c ^= 1;
		}
	}
}

int main(){
#ifndef ONLINE_JUDGE
	freopen("in.in","r",stdin);
	// freopen("out.out","w",stdout);
#endif
	init();
	T = read();
	while (T--) solve();
	return 0;
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 2ms
memory: 11596kb

input:

2
2 3
1 1

output:

Yes
0 0 1 
0 0 1 
No

result:

wrong answer 6 Mixed Submatrices Found, but 9 Expected (test case 1)