QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#790406 | #3836. So I'll Max Out My Constructive Algorithm Skills | Yurily# | AC ✓ | 28ms | 3956kb | C++20 | 1.5kb | 2024-11-28 11:29:17 | 2024-11-28 11:29:18 |
Judging History
answer
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<vector>
using namespace std;
const int N = 64;
int n, h[N + 3][N + 3];
vector<int>a;
void sol(){
scanf("%d", &n);
for(int i = 1; i <= n; i++)
for(int j = 1; j <= n; j++)
scanf("%d", &h[i][j]);
a.clear();
int p = 0;
for(int j = 2; j <= n; j++)
p += (h[1][j] > h[1][j - 1])?1:-1;
p += (h[2][n] > h[1][n])?1:-1;
for(int j = 1; j <= n; j++)
a.push_back(h[1][j]);
for(int j = n; j >= 1; j--){
if((n - j) & 1){
if(j < n)
p += (h[n][j] > h[n][j + 1])?1:-1;
for(int i = n - 1; i >= 2; i--)
p += (h[i][j] > h[i + 1][j])?1:-1;
for(int i = n; i >= 2; i--)
a.push_back(h[i][j]);
}
else {
if(j < n)
p += (h[2][j] > h[2][j + 1])?1:-1;
for(int i = 3; i <= n; i++)
p += (h[i][j] > h[i - 1][j])?1:-1;
for(int i = 2; i <= n; i++)
a.push_back(h[i][j]);
}
}
if(p > 0){
for(int i = (int)a.size() - 1; i > 0; i--)
printf("%d ", a[i]);
printf("%d\n", a[0]);
}
else {
for(int i = 0; i < (int)a.size() - 1; i++)
printf("%d ", a[i]);
printf("%d\n", a[(int)a.size() - 1]);
}
}
int main(){
int T;
scanf("%d", &T);
while(T--)
sol();
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3956kb
input:
1 2 4 3 2 1
output:
4 3 1 2
result:
ok correct
Test #2:
score: 0
Accepted
time: 1ms
memory: 3952kb
input:
100 9 30 75 35 51 25 19 76 65 62 11 56 63 60 77 48 28 26 74 16 44 46 41 17 8 66 61 42 29 7 43 38 40 31 27 10 39 52 23 58 80 50 20 33 69 47 79 1 5 49 22 37 71 18 70 54 72 4 64 55 34 12 6 15 14 53 45 13 32 59 73 57 81 36 3 78 24 2 68 9 67 21 7 11 28 2 19 9 41 24 17 34 5 10 42 18 47 33 35 22 8 49 1 29 ...
output:
36 14 54 79 52 29 16 11 56 44 7 23 1 72 53 3 78 45 4 5 58 43 46 63 60 41 38 80 49 64 13 24 2 32 55 22 50 40 17 77 48 8 31 20 37 34 59 68 9 73 12 71 33 27 66 28 26 61 10 69 18 6 57 67 21 81 15 70 47 39 42 74 62 65 76 19 25 51 35 75 30 21 46 39 14 33 17 34 35 20 37 27 31 23 16 6 12 22 5 10 8 3 25 45 4...
result:
ok correct
Test #3:
score: 0
Accepted
time: 3ms
memory: 3952kb
input:
100 11 77 68 83 43 116 28 75 74 34 94 5 22 64 13 4 107 1 61 59 85 101 97 26 56 3 66 25 80 79 53 41 78 115 99 16 100 98 72 121 31 102 93 38 44 7 114 57 71 36 76 95 105 117 92 29 54 81 18 58 19 73 118 90 24 112 21 113 91 50 60 86 103 110 52 40 9 55 6 42 67 119 39 48 63 62 37 2 82 8 27 89 96 109 15 111...
output:
17 12 8 6 113 54 7 99 26 22 64 56 16 114 81 91 42 27 10 70 30 46 89 67 50 18 57 100 3 13 4 66 98 71 58 60 119 96 47 35 88 20 109 39 86 19 36 72 25 107 1 80 121 76 73 103 48 15 11 23 104 14 111 63 110 118 95 31 79 61 59 53 102 105 90 52 62 51 120 32 84 33 69 37 40 24 117 93 41 85 101 78 38 92 112 9 2...
result:
ok correct
Test #4:
score: 0
Accepted
time: 28ms
memory: 3916kb
input:
100 59 788 1212 2725 713 3247 1378 94 940 1756 2647 888 149 3089 1871 1719 3225 285 1140 798 3375 1355 1207 1551 1022 2633 1647 3222 2979 1185 2489 2816 1709 1327 1623 523 3335 2542 892 3267 3009 2950 82 498 418 731 846 1847 2970 1929 1658 428 1273 3188 3122 2186 1631 1197 2420 326 1885 3328 414 126...
output:
788 1212 2725 713 3247 1378 94 940 1756 2647 888 149 3089 1871 1719 3225 285 1140 798 3375 1355 1207 1551 1022 2633 1647 3222 2979 1185 2489 2816 1709 1327 1623 523 3335 2542 892 3267 3009 2950 82 498 418 731 846 1847 2970 1929 1658 428 1273 3188 3122 2186 1631 1197 2420 326 1860 2284 2596 1599 3465...
result:
ok correct
Test #5:
score: 0
Accepted
time: 15ms
memory: 3944kb
input:
100 15 214 45 120 107 133 221 50 154 1 208 99 58 100 163 181 219 18 63 134 62 155 189 39 55 35 33 91 61 66 152 27 19 148 36 185 6 224 158 42 11 86 52 220 7 151 15 38 165 162 44 157 194 200 153 21 56 43 171 169 178 92 202 78 8 206 192 180 90 179 29 167 89 96 204 28 54 187 209 102 122 168 94 24 172 18...
output:
214 45 120 107 133 221 50 154 1 208 99 58 100 163 181 152 151 178 28 116 212 159 132 137 129 2 176 184 103 170 75 175 215 80 37 117 30 14 64 204 169 7 66 61 220 171 96 126 131 113 166 198 125 195 53 207 121 174 173 140 218 59 205 93 22 34 13 89 43 52 91 33 86 56 167 124 17 223 67 46 74 105 123 69 19...
result:
ok correct
Test #6:
score: 0
Accepted
time: 12ms
memory: 3932kb
input:
100 62 1751 1243 1461 493 3235 3723 2559 2110 1712 657 2195 1885 1652 3580 3744 2409 1011 1880 1976 1597 3621 3014 3498 356 1815 1583 66 45 104 3656 2961 2754 391 2381 3687 1894 2426 2877 3092 2027 2843 3101 1962 1977 1238 3161 245 2129 2946 516 1398 2893 1197 3090 2831 906 139 3318 2905 631 294 142...
output:
1843 1683 563 3609 672 1724 398 2059 227 1718 2551 1835 1331 1608 2894 1428 1020 3759 2936 432 2631 1023 2404 2801 1269 3790 3595 2776 2143 3278 143 2667 592 3315 1632 932 1991 977 1832 1360 717 1637 3129 2470 373 124 2922 1577 557 2605 992 1746 656 2749 1334 1993 3650 3269 3681 3551 3462 3110 389 2...
result:
ok correct
Test #7:
score: 0
Accepted
time: 11ms
memory: 3948kb
input:
100 49 7 1634 824 2118 1979 70 660 1913 913 1072 2027 1544 1793 1970 2 1495 1240 218 459 136 1872 1378 2373 308 2145 185 406 596 1374 2196 1573 1021 416 1298 46 1885 1708 1152 2285 1662 2377 2291 2187 1833 761 306 1352 745 2014 603 784 374 2136 1227 1771 2071 1443 360 91 955 1134 1009 1359 433 1013 ...
output:
7 1634 824 2118 1979 70 660 1913 913 1072 2027 1544 1793 1970 2 1495 1240 218 459 136 1872 1378 2373 308 2145 185 406 596 1374 2196 1573 1021 416 1298 46 1885 1708 1152 2285 1662 2377 2291 2187 1833 761 306 1352 745 2014 1005 504 2253 1315 1837 392 627 2166 1358 1158 2368 1261 944 2013 1534 1088 180...
result:
ok correct