QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#71934#5371. Matrixzhoukangyang0 2ms3516kbC++171.5kb2023-01-12 16:39:302023-01-12 16:39:31

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-01-12 16:39:31]
  • 评测
  • 测评结果:0
  • 用时:2ms
  • 内存:3516kb
  • [2023-01-12 16:39:30]
  • 提交

answer

#include<bits/stdc++.h>
#define L(i, j, k) for(int i = (j); i <= (k); ++i)
#define R(i, j, k) for(int i = (j); i >= (k); --i)
#define ll long long
#define sz(a) ((int) (a).size())
#define vi vector < int >
#define me(a, x) memset(a, x, sizeof(a))
#define ull unsigned long long
#define ld __float128
using namespace std;
const int N = 57;
int n, p[N];
ll a[N][N];
ll sx[N], sy[N];
void Main() {
	cin >> n;
	me(sx, 0), me(sy, 0);
	L(i, 1, n) {
		L(j, 1, n) {
			cin >> a[i][j];
			sx[i] += a[i][j];
			sy[j] += a[i][j];
		}
	} 
	L(i, 1, n) if(sx[i] != sx[1] || sy[i] != sy[1]) {
		cout << -1 << '\n';
		return ;
	}
	cout << n * n - 2 * n + 2 << '\n';
	L(i, 1, n) {
		L(j, 1, i - 2) {
			int w = a[i][j];
			cout << w << ' ';
			L(k, 1, j - 1) p[k] = k;
			L(k, i + 1, n) p[k] = k;
			p[i] = j;
			L(k, j, i - 1) p[k] = k + 1;
			L(k, 1, n) cout << p[k] << ' ', a[k][p[k]] -= w;
			cout << '\n';
		}
	}
	
	L(i, 1, n) {
		L(j, i + 1, n) {
			int w = a[i][j];
			cout << w << ' ';
			L(k, 1, i - 1) p[k] = k;
			L(k, j + 1, n) p[k] = k;
			p[i] = j;
			L(k, i + 1, j) p[k] = k - 1;
			L(k, 1, n) L(t, k + 1, n) assert(p[k] != p[t]);
			L(k, 1, n) cout << p[k] << ' ', a[k][p[k]] -= w;
			cout << '\n';
		}
	}
	int w = a[1][1];
	cout << w << ' ';
	L(i, 1, n) cout << i << ' ', a[i][i] -= w;
	cout << '\n';
	L(i, 1, n) L(j, 1, n) assert(!a[i][j]);
}

int main () {
	ios :: sync_with_stdio(false);
	cin.tie(0); cout.tie(0); 
	int t;
	cin >> t;
	while(t--) Main();
	return 0;
}

詳細信息

Subtask #1:

score: 0
Wrong Answer

Test #1:

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

input:

10
5
41 18467 6334 26500 2995
19169 15724 11478 29358 -21392
26962 24464 5705 28145 -30939
23281 16827 9961 491 3777
-15116 -21145 20859 -30157 99896
5
4827 5436 32391 14604 1869
3902 153 292 12382 42398
17421 18716 19718 19895 -16623
5447 21726 14771 11538 5645
27530 13096 -8045 708 25838
5
41879 4...

output:

17
26962 2 3 1 4 5 
23281 2 3 4 1 5 
16827 1 3 4 2 5 
-15116 2 3 4 5 1 
-21145 1 3 4 5 2 
20859 1 2 4 5 3 
-16660 2 1 3 4 5 
6334 3 1 2 4 5 
26500 4 1 2 3 5 
2995 5 1 2 3 4 
-19331 1 3 2 4 5 
29358 1 4 2 3 5 
-21392 1 5 2 3 4 
3439 1 2 4 3 5 
-30939 1 2 5 3 4 
19179 1 2 3 5 4 
3186 1 2 3 4 5 
17
174...

result:

wrong answer wrong solution, actuaclly there's no solution (test case 1)

Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Skipped

Dependency #1:

0%