QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#28334 | #2956. Statues | hld67890# | AC ✓ | 3ms | 3260kb | C++17 | 2.0kb | 2022-04-13 17:13:00 | 2022-04-29 09:38:40 |
Judging History
answer
#include <stdio.h>
#include <algorithm>
#include <queue>
using namespace std;
struct node {
int x , i , j;
} s[12000];
int top;
int n , m;
int a[120][120];
int ans;
bool cmp ( node x1 , node x2 ) {
return x1.x < x2.x;
}
void solve () {
int i , j , ret;
queue < int > q;
for ( i = 2 ; i <= n + m ; i++ ) {
for ( j = 1 ; j <= n ; j++ ) {
if ( i - j <= m && i - j >= 1 && a[j][i-j] != -1 ) {
q.push ( i );
}
}
}
top = 0;
for ( i = 1 ; i <= n ; i++ ) {
for ( j = 1 ; j <= m ; j++ ) {
if ( a[i][j] == -1 ) continue;
top++;
s[top].x = a[i][j];
s[top].i = i;
s[top].j = j;
}
}
sort ( s + 1 , s + top + 1 , cmp );
ret = 0;
for ( i = 1 ; i <= top ; i++ ) {
//printf ( "%d %d %d %d\n" , s[i].i , s[i].j , s[i].x , q.front () );
if ( q.front () != s[i].i + s[i].j ) {
ret++;
}
q.pop ();
}
ans = min ( ans , ret );
//printf ( "%d\n" , ret );
}
void work () {
int i , j;
scanf ( "%d%d" , &n , &m );
for ( i = 1 ; i <= n ; i++ ) {
for ( j = 1 ; j <= m ; j++ ) {
scanf ( "%d" , &a[i][j] );
}
}
ans = n * m;
solve ();
for ( i = 1 ; i <= n ; i++ ) {
for ( j = 1 ; j <= m / 2 ; j++ ) {
swap ( a[i][j] , a[i][m-j+1] );
}
}
/*for ( i = 1 ; i <= n ; i++ ) {
for ( j = 1 ; j <= m ; j++ ) {
printf ( "%d " , a[i][j] );
}
printf ( "\n" );
}
printf ( "\n" );*/
solve ();
for ( i = 1 ; i <= n / 2 ; i++ ) {
for ( j = 1 ; j <= m ; j++ ) {
swap ( a[i][j] , a[n-i+1][j] );
}
}
/*for ( i = 1 ; i <= n ; i++ ) {
for ( j = 1 ; j <= m ; j++ ) {
printf ( "%d " , a[i][j] );
}
printf ( "\n" );
}
printf ( "\n" );*/
solve ();
for ( i = 1 ; i <= n ; i++ ) {
for ( j = 1 ; j <= m / 2 ; j++ ) {
swap ( a[i][j] , a[i][m-j+1] );
}
}
/*for ( i = 1 ; i <= n ; i++ ) {
for ( j = 1 ; j <= m ; j++ ) {
printf ( "%d " , a[i][j] );
}
printf ( "\n" );
}
printf ( "\n" );*/
solve ();
printf ( "%d\n" , ans );
}
int main () {
work ();
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 2ms
memory: 3172kb
input:
50 50 9946 213 7427 7298 9772 2466 4890 2062 2490 1538 5605 4546 5426 2974 7693 5133 206 1329 7853 5669 8991 8828 1006 808 2227 1878 8900 8948 2755 8784 2564 5954 348 1718 2880 5820 7112 8161 4337 7247 5447 7465 1280 7708 1567 6280 129 9961 5758 9546 6412 3445 7559 7648 3160 3649 2388 7527 1800 4392...
output:
2466
result:
ok single line: '2466'
Test #2:
score: 0
Accepted
time: 3ms
memory: 3220kb
input:
50 50 9711 1938 4236 1965 4256 3579 7882 3432 4879 2623 8535 4292 9663 1737 4394 3897 73 429 1926 6010 759 7172 824 7860 8172 1010 2096 3107 95 8163 7594 4420 6514 3476 1224 8069 5763 3423 5854 937 2430 3518 4441 5735 9292 3440 1772 8594 9373 809 2473 4660 6862 595 1481 2211 3078 3507 8664 3429 2275...
output:
2458
result:
ok single line: '2458'
Test #3:
score: 0
Accepted
time: 3ms
memory: 3240kb
input:
50 50 5922 2303 8307 7745 4554 2369 2512 747 3347 6779 6952 3114 6768 5910 4358 4524 452 3370 5212 1721 3469 7412 6516 2769 1201 7653 2420 2075 6595 535 2525 8813 34 316 5904 5785 2207 6655 6062 1828 6280 5691 2027 322 5830 2778 2622 1453 79 2597 9400 1109 937 3051 8142 1793 4508 7661 6756 931 3875 ...
output:
2465
result:
ok single line: '2465'
Test #4:
score: 0
Accepted
time: 3ms
memory: 3212kb
input:
50 50 3899 4000 3573 2348 6892 8166 9845 7650 1533 7989 4832 1843 5536 5635 7278 3780 905 5743 4353 3262 9901 6617 8626 7337 9942 2206 9325 9588 2401 2476 3126 754 629 4676 4662 8590 3855 7917 9558 5855 7694 5124 9926 6726 4584 5329 4651 2676 4151 9286 7219 1049 3652 1889 6982 1703 238 320 5883 5269...
output:
2463
result:
ok single line: '2463'
Test #5:
score: 0
Accepted
time: 3ms
memory: 3160kb
input:
50 50 5816 2852 402 -1 1092 2198 8089 4041 973 2859 8152 6819 4643 3383 2703 7538 8434 2089 8019 -1 3020 9375 -1 6689 2153 4471 -1 -1 8138 -1 6371 145 5120 -1 860 -1 -1 3082 1138 8343 144 5318 5104 3003 1854 5155 4154 -1 6894 4546 -1 -1 -1 2424 -1 6176 6612 -1 9708 -1 8761 1794 8190 8864 1641 -1 515...
output:
1667
result:
ok single line: '1667'
Test #6:
score: 0
Accepted
time: 3ms
memory: 3244kb
input:
50 50 3034 -1 832 -1 -1 8832 4295 -1 -1 -1 6633 1519 593 -1 7211 -1 643 4929 6378 3389 9150 784 -1 1160 8328 8659 3153 -1 9407 7144 -1 -1 7802 -1 -1 -1 -1 9509 8975 7450 2930 9933 -1 9669 6096 6697 6718 -1 -1 -1 -1 -1 5514 6401 1678 1546 124 2380 1120 5646 -1 2247 -1 3356 9218 -1 411 112 -1 -1 9175 ...
output:
1625
result:
ok single line: '1625'
Test #7:
score: 0
Accepted
time: 3ms
memory: 3188kb
input:
50 50 4644 6810 7319 -1 -1 -1 9778 9045 -1 489 5685 -1 9894 -1 3736 1901 -1 2356 3765 4457 1799 4343 6971 5374 2630 -1 8803 8856 7374 5802 -1 -1 7207 3728 1769 -1 2902 -1 2006 9139 7687 3651 7298 6342 8049 6209 2550 -1 3184 -1 7366 184 9391 5873 3627 -1 -1 -1 5757 2553 8108 9859 2513 1890 5078 -1 78...
output:
1650
result:
ok single line: '1650'
Test #8:
score: 0
Accepted
time: 3ms
memory: 3188kb
input:
50 50 8062 8954 -1 160 4243 7311 1612 6614 8744 1024 864 1595 938 9966 7692 4661 6629 1768 2211 -1 8131 -1 -1 9884 -1 -1 9370 320 -1 -1 9019 -1 9674 6676 8367 3855 -1 6371 3447 3333 4427 -1 -1 -1 -1 3945 4987 -1 8656 8542 -1 1114 4336 5768 5923 9494 9343 9605 -1 3339 6702 1147 5515 -1 6504 7288 4570...
output:
1639
result:
ok single line: '1639'
Test #9:
score: 0
Accepted
time: 3ms
memory: 3148kb
input:
50 50 -1 -1 400 3493 3604 -1 2 -1 -1 5889 4091 990 3940 -1 5627 117 -1 -1 -1 -1 1280 8075 -1 8774 -1 -1 -1 -1 -1 -1 5732 4834 -1 -1 -1 6924 -1 -1 -1 1726 -1 5373 7593 -1 -1 1393 -1 -1 -1 -1 9384 3353 -1 8892 1914 2848 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 658 -1 -1 9039 5076 3025 -1 -1 -1 -1 -1 500...
output:
790
result:
ok single line: '790'
Test #10:
score: 0
Accepted
time: 0ms
memory: 3180kb
input:
3 4 2 -1 9 6 10 8 -1 4 1 3 5 7
output:
5
result:
ok single line: '5'
Test #11:
score: 0
Accepted
time: 0ms
memory: 3260kb
input:
50 50 -1 -1 -1 2186 -1 -1 -1 -1 -1 -1 -1 -1 6001 -1 2920 -1 -1 9816 -1 -1 -1 -1 8416 -1 4951 4709 -1 -1 9297 -1 -1 9723 -1 481 9915 -1 -1 -1 -1 6273 4034 2171 -1 1753 6065 -1 3254 -1 -1 6752 -1 -1 4287 -1 -1 5965 -1 -1 -1 -1 4522 7278 -1 -1 -1 425 9813 -1 5772 -1 -1 7426 7254 2899 -1 -1 7007 579 125...
output:
819
result:
ok single line: '819'
Test #12:
score: 0
Accepted
time: 3ms
memory: 3212kb
input:
50 50 1273 1025 5432 -1 -1 -1 -1 -1 -1 6897 -1 4105 4905 -1 9002 -1 -1 3164 -1 -1 -1 -1 -1 651 -1 -1 -1 -1 -1 -1 -1 -1 -1 4671 5400 -1 2776 -1 -1 5390 -1 -1 3039 9202 -1 7894 -1 -1 5415 -1 1601 -1 3404 -1 -1 -1 -1 935 -1 9330 -1 2870 2199 586 -1 -1 6807 -1 -1 -1 -1 -1 -1 8478 8311 -1 -1 -1 -1 -1 -1 ...
output:
839
result:
ok single line: '839'
Test #13:
score: 0
Accepted
time: 3ms
memory: 3228kb
input:
50 50 -1 -1 3084 -1 2294 4011 7880 221 -1 -1 -1 -1 -1 6981 -1 -1 3257 3844 -1 3164 -1 2909 -1 -1 1749 -1 3695 -1 5152 8668 -1 -1 -1 -1 -1 6595 8978 4860 5655 -1 -1 7449 -1 -1 -1 -1 -1 -1 -1 2917 -1 -1 981 -1 2640 -1 -1 -1 7562 -1 -1 -1 -1 957 -1 -1 -1 -1 -1 2895 -1 2596 7664 7638 3747 -1 -1 -1 3792 ...
output:
880
result:
ok single line: '880'
Test #14:
score: 0
Accepted
time: 1ms
memory: 3216kb
input:
50 50 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 645 -1 -1 -1 -1...
output:
15
result:
ok single line: '15'
Test #15:
score: 0
Accepted
time: 3ms
memory: 3252kb
input:
50 50 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ...
output:
14
result:
ok single line: '14'
Test #16:
score: 0
Accepted
time: 3ms
memory: 3256kb
input:
50 50 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 4657 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -...
output:
21
result:
ok single line: '21'
Test #17:
score: 0
Accepted
time: 3ms
memory: 3212kb
input:
50 50 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 8241 -1 -1 -1 1231 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1...
output:
17
result:
ok single line: '17'
Test #18:
score: 0
Accepted
time: 1ms
memory: 3200kb
input:
1 1 1
output:
0
result:
ok single line: '0'
Test #19:
score: 0
Accepted
time: 1ms
memory: 3232kb
input:
1 1 -1
output:
0
result:
ok single line: '0'
Test #20:
score: 0
Accepted
time: 2ms
memory: 3148kb
input:
3 4 26 20 14 12 28 22 -1 16 30 -1 24 18
output:
0
result:
ok single line: '0'
Test #21:
score: 0
Accepted
time: 3ms
memory: 3240kb
input:
3 4 30 -1 24 18 28 22 -1 16 26 20 14 12
output:
0
result:
ok single line: '0'
Test #22:
score: 0
Accepted
time: 1ms
memory: 3156kb
input:
3 4 18 24 -1 30 16 -1 22 28 12 14 20 26
output:
0
result:
ok single line: '0'
Test #23:
score: 0
Accepted
time: 2ms
memory: 3120kb
input:
3 4 12 14 20 26 16 -1 22 28 18 24 -1 30
output:
0
result:
ok single line: '0'
Test #24:
score: 0
Accepted
time: 2ms
memory: 3160kb
input:
1 50 851 1279 618 9422 6753 7268 641 94 2250 8079 6045 6952 9732 3362 5489 7098 5790 328 4561 4418 4940 2842 638 2252 912 826 9392 1208 7921 4652 4863 8762 3579 5828 3245 9819 3811 346 4803 317 5764 4714 983 4220 9707 4680 3639 7568 747 1621
output:
48
result:
ok single line: '48'
Test #25:
score: 0
Accepted
time: 3ms
memory: 3160kb
input:
1 50 3754 -1 -1 4165 7487 6349 -1 4648 -1 -1 -1 2598 7503 -1 -1 -1 4660 8973 6599 6077 3558 7661 -1 -1 -1 9787 6166 7890 2425 -1 3139 -1 1480 8280 2593 7761 7309 -1 -1 7184 2512 -1 -1 -1 -1 -1 2523 -1 2145 9082
output:
26
result:
ok single line: '26'
Test #26:
score: 0
Accepted
time: 2ms
memory: 3188kb
input:
50 1 241 8851 2415 9895 8146 2809 427 2037 3004 7220 6634 3123 5031 309 6103 4077 9250 5534 2353 8343 987 6529 3554 7478 817 276 6982 443 3603 9793 8699 464 2164 4026 1572 5371 8526 8425 3161 4767 6608 8326 7919 3682 6326 7794 4928 9162 1156 191
output:
49
result:
ok single line: '49'
Test #27:
score: 0
Accepted
time: 2ms
memory: 3176kb
input:
50 1 -1 -1 -1 3412 9539 -1 -1 -1 4020 9339 -1 -1 2294 -1 -1 8492 7003 4004 2048 -1 9358 2146 4306 -1 1147 -1 -1 6118 2014 -1 -1 9248 7512 -1 -1 -1 6314 -1 -1 -1 9925 -1 -1 3796 2222 -1 5305 -1 1675 -1
output:
19
result:
ok single line: '19'
Test #28:
score: 0
Accepted
time: 0ms
memory: 3164kb
input:
24 17 -1 -1 -1 -1 -1 -1 4842 -1 9735 -1 3211 9398 9854 -1 -1 -1 -1 1988 5104 8376 343 -1 -1 5539 6918 7763 -1 -1 -1 2927 5347 -1 -1 6488 4446 -1 -1 5106 619 -1 -1 717 -1 -1 -1 1595 -1 -1 3507 -1 -1 -1 7915 -1 -1 -1 -1 -1 1294 -1 -1 -1 -1 -1 1724 -1 569 -1 7999 -1 8063 9281 -1 3833 6925 6891 -1 -1 -1...
output:
171
result:
ok single line: '171'
Test #29:
score: 0
Accepted
time: 2ms
memory: 3204kb
input:
25 14 2410 8726 -1 4810 385 -1 -1 5956 1131 3647 -1 3672 -1 -1 4465 -1 3903 8633 3670 -1 -1 -1 -1 8759 2281 3085 -1 -1 5106 2213 -1 -1 -1 2507 6063 -1 9209 9417 -1 -1 -1 5580 3536 2095 8399 3540 -1 -1 -1 -1 6165 8860 2502 -1 9872 2080 3304 4240 -1 2773 1853 -1 -1 3841 4775 4417 634 -1 8744 -1 7751 -...
output:
193
result:
ok single line: '193'
Test #30:
score: 0
Accepted
time: 3ms
memory: 3192kb
input:
10 13 -1 -1 -1 2516 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 337 -1 8279 -1 -1 -1 -1 6741 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 9199 -1 -1 -1 -1 -1 -1 -1 3674 -1 7443 -1 5480 6559 -1 -1 -1 8702 -1 3644 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 3020 -1 -1 -1 -1 -1 -1 -1 -1 -1 1264 -1 -1 2533 -1 ...
output:
17
result:
ok single line: '17'
Test #31:
score: 0
Accepted
time: 1ms
memory: 3252kb
input:
46 10 -1 -1 908 -1 7690 525 -1 -1 6229 -1 -1 9380 500 -1 -1 6988 5478 -1 2114 -1 1782 -1 2413 9994 656 9187 1013 7074 1702 -1 5941 4576 4973 409 -1 8318 -1 -1 9502 3862 -1 1933 8923 -1 1739 -1 -1 6617 4008 7865 4665 4662 2789 3170 -1 -1 -1 4843 2094 3746 16 9216 -1 8618 -1 3991 482 987 -1 7292 8866 ...
output:
259
result:
ok single line: '259'
Test #32:
score: 0
Accepted
time: 2ms
memory: 3196kb
input:
36 30 5061 3988 427 2243 528 7377 -1 6288 8759 8814 3426 -1 -1 503 452 -1 -1 2313 -1 -1 -1 1196 -1 -1 9514 -1 -1 -1 -1 -1 -1 -1 3244 -1 7017 -1 5633 -1 -1 -1 -1 5866 1242 -1 5622 -1 -1 -1 -1 5643 -1 1376 -1 -1 -1 -1 -1 574 -1 -1 -1 -1 9754 -1 -1 9284 6865 8246 -1 -1 2146 6258 973 -1 -1 8872 9185 -1 ...
output:
528
result:
ok single line: '528'
Test #33:
score: 0
Accepted
time: 3ms
memory: 3160kb
input:
27 10 3360 4639 4882 -1 -1 -1 8801 -1 4199 -1 5235 7020 9375 6300 -1 -1 3917 -1 -1 -1 8758 2408 2594 3150 3328 -1 2664 9407 -1 -1 5414 7781 -1 -1 6381 7655 415 1801 6947 1734 6403 6718 2365 -1 9498 3599 -1 4787 4709 -1 8715 4383 5258 -1 3483 -1 8296 7864 -1 -1 -1 5364 74 8575 -1 2436 2924 8696 -1 41...
output:
144
result:
ok single line: '144'
Test #34:
score: 0
Accepted
time: 3ms
memory: 3216kb
input:
31 45 1487 1221 9276 -1 2493 -1 -1 7674 -1 7844 9949 768 8411 6006 8044 9575 8078 8749 7173 1529 3926 1372 3377 3680 345 9351 9032 7164 7976 -1 7603 -1 3667 7895 8442 3180 6860 -1 7891 4132 9829 757 7280 4471 9610 7633 3034 8197 8546 5203 1246 7313 7488 8273 -1 8509 3731 4601 3604 5850 2981 1488 220...
output:
1131
result:
ok single line: '1131'
Test #35:
score: 0
Accepted
time: 3ms
memory: 3184kb
input:
27 23 -1 -1 -1 6745 3451 8088 -1 5166 -1 6631 -1 -1 7153 -1 -1 2658 -1 -1 -1 8530 143 -1 -1 4517 -1 -1 7147 6215 5785 -1 4376 -1 -1 -1 1068 8919 -1 4051 5297 -1 4446 5832 4107 5998 2834 -1 893 9638 -1 -1 1878 5994 5302 -1 -1 9072 -1 -1 2345 2135 355 6608 4952 -1 7200 870 4199 913 -1 -1 -1 3404 2741 ...
output:
282
result:
ok single line: '282'
Test #36:
score: 0
Accepted
time: 3ms
memory: 3236kb
input:
13 27 1445 3135 914 6944 8073 1760 8718 9810 8146 -1 2654 3412 7775 3580 1324 322 8123 9257 5467 4369 4443 4309 496 1503 8608 6960 4022 5864 9812 6765 5360 8353 6461 8679 7831 -1 2305 3566 8731 5697 2989 477 4182 2579 6078 6767 2859 5741 3504 287 9953 5123 186 6670 6807 6365 1797 373 8293 3012 1178 ...
output:
330
result:
ok single line: '330'
Test #37:
score: 0
Accepted
time: 3ms
memory: 3156kb
input:
18 42 3316 251 -1 7176 7293 8074 -1 4534 6268 8139 5633 9502 3967 8315 -1 9178 -1 8555 2581 7065 7709 -1 7246 643 1055 2551 1523 -1 75 -1 2920 4321 5108 5269 -1 -1 7104 6286 -1 1848 2092 -1 9655 833 -1 -1 1592 2819 6068 8136 9553 2130 2822 5977 8933 9329 5078 1655 3356 4367 -1 -1 3864 -1 513 3033 -1...
output:
583
result:
ok single line: '583'