QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#71935 | #5371. Matrix | zhoukangyang | 30 | 2ms | 3516kb | C++17 | 1.6kb | 2023-01-12 16:43:22 | 2023-01-12 17:10:07 |
Judging History
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) L(j, 1, n) if(a[i][j] < 0) {
cout << -1 << '\n';
return ;
}
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: 30
Accepted
Test #1:
score: 30
Accepted
time: 2ms
memory: 3344kb
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:
-1 -1 17 33885 2 3 1 4 5 44465 2 3 4 1 5 23080 1 3 4 2 5 27473 2 3 4 5 1 66127 1 3 4 5 2 38724 1 2 4 5 3 -63312 2 1 3 4 5 33247 3 1 2 4 5 26106 4 1 2 3 5 48874 5 1 2 3 4 -147496 1 3 2 4 5 46545 1 4 2 3 5 13600 1 5 2 3 4 -175946 1 2 4 3 5 82580 1 2 5 3 4 -92867 1 2 3 5 4 187532 1 2 3 ...
result:
ok good solution (10 test cases)
Test #2:
score: 0
Accepted
time: 0ms
memory: 3384kb
input:
10 5 59894 57729 53053 37667 58044 49556 41863 58059 44760 72149 49555 42862 54181 52697 67092 55846 40495 51765 66802 51479 51536 83438 49329 64461 17623 5 6224 11008 5844 32609 13458 14989 32702 3195 20485 -2228 3093 14343 30523 1587 19597 29314 9503 7448 25200 -2322 15523 1587 22133 -10738 40638 ...
output:
17 49555 2 3 1 4 5 55846 2 3 4 1 5 40495 1 3 4 2 5 51536 2 3 4 5 1 83438 1 3 4 5 2 49329 1 2 4 5 3 -99208 2 1 3 4 5 53053 3 1 2 4 5 37667 4 1 2 3 5 58044 5 1 2 3 4 -222811 1 3 2 4 5 44760 1 4 2 3 5 72149 1 5 2 3 4 -227947 1 2 4 3 5 67092 1 2 5 3 4 -132824 1 2 3 5 4 286213 1 2 3 4 5 ...
result:
ok good solution (10 test cases)
Test #3:
score: 0
Accepted
time: 2ms
memory: 3328kb
input:
10 5 10202 3625 26477 4414 17773 9314 25824 29334 25874 -27855 24372 20159 11833 28070 -21943 7487 28297 7518 8177 11012 11116 -15414 -12671 -4044 83504 5 80335 81240 95764 92557 91633 81674 87052 107785 86199 78819 83374 82671 109099 81197 85188 80115 80496 89595 108544 82779 116031 110070 39286 73...
output:
-1 17 83374 2 3 1 4 5 80115 2 3 4 1 5 80496 1 3 4 2 5 116031 2 3 4 5 1 110070 1 3 4 5 2 39286 1 2 4 5 3 -198280 2 1 3 4 5 95764 3 1 2 4 5 92557 4 1 2 3 5 91633 5 1 2 3 4 -362301 1 3 2 4 5 86199 1 4 2 3 5 78819 1 5 2 3 4 -344801 1 2 4 3 5 85188 1 2 5 3 4 -182608 1 2 3 5 4 489987 1 2 3...
result:
ok good solution (10 test cases)
Test #4:
score: 0
Accepted
time: 2ms
memory: 3372kb
input:
10 5 22335 24708 38072 45631 16687 27829 32738 19360 45510 21996 22430 32748 37233 30145 24877 38308 18739 18383 18259 53744 36531 38500 34385 7888 30129 5 44671 57452 39279 47542 49809 36827 56746 58358 41115 45707 57345 54779 56063 52429 18137 37825 52474 36230 66538 45686 62085 17302 48823 31129 ...
output:
17 22430 2 3 1 4 5 38308 2 3 4 1 5 18739 1 3 4 2 5 36531 2 3 4 5 1 38500 1 3 4 5 2 34385 1 2 4 5 3 -72561 2 1 3 4 5 38072 3 1 2 4 5 45631 4 1 2 3 5 16687 5 1 2 3 4 -135148 1 3 2 4 5 45510 1 4 2 3 5 21996 1 5 2 3 4 -136318 1 2 4 3 5 24877 1 2 5 3 4 -55672 1 2 3 5 4 165466 1 2 3 4 5 1...
result:
ok good solution (10 test cases)
Test #5:
score: 0
Accepted
time: 1ms
memory: 3432kb
input:
10 5 14423 3527 11600 26969 1588 14015 5565 28 21543 16956 25347 2088 2943 12637 15092 22409 26463 5049 4681 -495 -18087 20464 38487 -7723 24966 5 608 32060 21221 1758 18035 29954 20888 14146 690 8004 7949 12843 21430 25620 5840 748 27067 4536 20783 20548 34423 -19176 12349 24831 21255 5 64025 55878...
output:
-1 -1 17 81097 2 3 1 4 5 72158 2 3 4 1 5 81566 1 3 4 2 5 44916 2 3 4 5 1 46622 1 3 4 5 2 66769 1 2 4 5 3 -142293 2 1 3 4 5 58693 3 1 2 4 5 74469 4 1 2 3 5 69195 5 1 2 3 4 -257596 1 3 2 4 5 52199 1 4 2 3 5 76646 1 5 2 3 4 -248236 1 2 4 3 5 49978 1 2 5 3 4 -133887 1 2 3 5 4 329964 1 2 ...
result:
ok good solution (10 test cases)
Test #6:
score: 0
Accepted
time: 2ms
memory: 3372kb
input:
10 5 18115 1679 17110 25898 28 23073 788 23977 18132 -3140 29956 28689 26113 10008 -31936 12941 15790 1723 21363 11013 -21255 15884 -6093 -12571 86865 5 127174 109596 107467 104281 105705 124370 103467 113729 125263 87394 128549 116691 134564 123221 51198 112072 118025 131046 104994 88086 62058 1064...
output:
-1 17 128549 2 3 1 4 5 112072 2 3 4 1 5 118025 1 3 4 2 5 62058 2 3 4 5 1 106444 1 3 4 5 2 67417 1 2 4 5 3 -193083 2 1 3 4 5 107467 3 1 2 4 5 104281 4 1 2 3 5 105705 5 1 2 3 4 -413419 1 3 2 4 5 125263 1 4 2 3 5 87394 1 5 2 3 4 -342795 1 2 4 3 5 51198 1 2 5 3 4 -147833 1 2 3 5 4 475480...
result:
ok good solution (10 test cases)
Test #7:
score: 0
Accepted
time: 2ms
memory: 3516kb
input:
10 5 18337 1278 12393 7636 25608 30714 28164 31591 19949 -45166 19135 2505 13337 10004 20271 16337 2623 28664 9970 7658 -19271 30682 -20733 17693 56881 5 118623 106427 108494 117715 101283 127994 107536 109218 123168 84626 127738 106914 105591 113982 98317 128516 118161 100285 131953 73627 49671 113...
output:
-1 17 127738 2 3 1 4 5 128516 2 3 4 1 5 118161 1 3 4 2 5 49671 2 3 4 5 1 113504 1 3 4 5 2 128954 1 2 4 5 3 -199498 2 1 3 4 5 108494 3 1 2 4 5 117715 4 1 2 3 5 101283 5 1 2 3 4 -428372 1 3 2 4 5 123168 1 4 2 3 5 84626 1 5 2 3 4 -424824 1 2 4 3 5 98317 1 2 5 3 4 -218502 1 2 3 5 4 52359...
result:
ok good solution (10 test cases)
Test #8:
score: 0
Accepted
time: 0ms
memory: 3432kb
input:
10 5 32179 16595 20169 2327 25783 12042 31310 28182 11058 14461 7926 9487 1670 32528 45442 5651 2258 7213 9860 72071 39255 37403 39819 41280 -60704 5 58360 64228 60090 62746 84076 74052 61459 76336 59121 58532 70485 80483 66556 57499 54477 64875 78368 84232 74216 27809 61728 44962 42286 75918 104606...
output:
-1 17 70485 2 3 1 4 5 64875 2 3 4 1 5 78368 1 3 4 2 5 61728 2 3 4 5 1 44962 1 3 4 5 2 42286 1 2 4 5 3 -132860 2 1 3 4 5 60090 3 1 2 4 5 62746 4 1 2 3 5 84076 5 1 2 3 4 -244082 1 3 2 4 5 59121 1 4 2 3 5 58532 1 5 2 3 4 -234720 1 2 4 3 5 54477 1 2 5 3 4 -121167 1 2 3 5 4 320583 1 2 3 4...
result:
ok good solution (10 test cases)
Test #9:
score: 0
Accepted
time: 2ms
memory: 3376kb
input:
10 5 27577 12750 14007 23729 29929 24081 2995 2678 24676 53562 27753 20899 11784 15565 31991 3093 13608 6172 11243 73876 25488 57740 73351 32779 -81366 5 10168 5055 11191 5973 15469 8922 6748 5651 10986 15549 2144 16446 31577 26517 -28828 14629 29916 5874 15791 -18354 11993 -10309 -6437 -11411 64020...
output:
-1 -1 17 25382 2 3 1 4 5 53308 2 3 4 1 5 42101 1 3 4 2 5 49578 2 3 4 5 1 30015 1 3 4 5 2 50670 1 2 4 5 3 -72429 2 1 3 4 5 34237 3 1 2 4 5 34961 4 1 2 3 5 55326 5 1 2 3 4 -154598 1 3 2 4 5 51198 1 4 2 3 5 12573 1 5 2 3 4 -169300 1 2 4 3 5 63571 1 2 5 3 4 -93886 1 2 3 5 4 200948 1 2 3 ...
result:
ok good solution (10 test cases)
Test #10:
score: 0
Accepted
time: 2ms
memory: 3368kb
input:
10 5 52175 34573 47184 34242 48829 39726 48464 56486 42655 29672 58676 54948 45757 42343 15279 45044 49757 42978 51268 27956 21382 29261 24598 46495 95267 5 115939 94609 88842 92104 98792 89855 95791 96911 101968 105761 111710 103031 92884 106351 76310 116598 114955 95676 118795 44262 56184 81900 11...
output:
17 58676 2 3 1 4 5 45044 2 3 4 1 5 49757 1 3 4 2 5 21382 2 3 4 5 1 29261 1 3 4 5 2 24598 1 2 4 5 3 -90529 2 1 3 4 5 47184 3 1 2 4 5 34242 4 1 2 3 5 48829 5 1 2 3 4 -147634 1 3 2 4 5 42655 1 4 2 3 5 29672 1 5 2 3 4 -127699 1 2 4 3 5 15279 1 2 5 3 4 -47285 1 2 3 5 4 183571 1 2 3 4 5 1...
result:
ok good solution (10 test cases)
Subtask #2:
score: 0
Dangerous Syscalls
Dependency #1:
100%
Accepted
Test #11:
score: 0
Dangerous Syscalls
input:
10 30 3303373 3309415 3289962 3309855 3312694 3291644 3309691 3294908 3296047 3312358 3320956 3313078 3317639 3306313 3317589 3316838 3308551 3311957 3312323 3293346 3313147 3293374 3301630 3308503 3311855 3315564 3317401 3290456 3301303 3309428 3308147 3304361 3303158 3313330 3307333 3299369 330747...
output:
842 3299565 2 3 1 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 3310658 2 3 4 1 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 3319707 1 3 4 2 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 3315105 2 3 4 5 1 6 7 8 9 ...
result:
Subtask #3:
score: 0
Skipped
Dependency #1:
100%
Accepted
Dependency #2:
0%