QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#804295#9874. Matrix Constructionucup-team139#WA 0ms3552kbC++14923b2024-12-07 21:32:042024-12-07 21:32:05

Judging History

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

  • [2024-12-07 21:32:05]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3552kb
  • [2024-12-07 21:32:04]
  • 提交

answer

#include <bits/stdc++.h>

#define int int64_t
using namespace std;

vector<vector<int> > solve(int n, int m) {
	vector<vector<int> > a(n, vector<int>(m));
	int c = 1;
	for(int i=0; i<n; ++i) {
		for(int j=0; j<m; ++j) {
			a[i][j]=c++;
		}
	}
	return a;
}
bool check(vector<vector<int> >& a) {
	set<int> s;
	int n = a.size();
	int m = a[0].size();
	for(int i=0; i<n; ++i) {
		for(int j=0; j<m; ++j) {
			if(s.count(a[i][j])) return 0;
			s.insert(a[i][j]);
		}
	}
	return 1;
}

signed main() {
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	/*for(int n=1; n<100; ++n) {
		for(int m=1; m<100; ++m) {
			auto a = solve(n,m);
			if(!check(a)) {
				cerr<<"wrong "<<n<<' '<<m<<endl;
				return 1;
			}
		}
	}
	return 0;
	*/
	int t;
	cin>>t;
	while(t--) {
	int n,m;
	cin>>n>>m;
	auto a = solve(n,m);
	cout<<"Yes\n";
	for(int i=0; i<n; ++i) {
		for(int j=0; j<m; ++j) {
			cout<<a[i][j]<<' ';
		}
		cout<<'\n';
	}
	}
	return 0;
}


Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

2
1 1
2 3

output:

Yes
1 
Yes
1 2 3 
4 5 6 

result:

wrong answer Duplicate sum found for adjacent elements at (1,2) and (1,3) (test case 2)