编号 题目 状态 分数 总时间 内存 代码 / 答案文件 提交者 提交时间
#30411 #2065. 数字华容道 Time Limit Exceeded 70 9122 ms 8108 K C / 895 B C192023211917 2025-03-16 10:28:41
显示原始代码

#include <stdio.h>
#include <stdlib.h>
int main() {
    int m, n;
    scanf("%d %d", &n, &m);
    int len = m * n;
    len--;
    int** a = (int**)malloc(n * sizeof(int*));
    for (int i = 0; i < n; i++) {
        a[i] = (int*)malloc(m * sizeof(int));
    }
    int* b = (int*)malloc(len * sizeof(int));
    int pos_i, t, pos;
    t = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            scanf("%d", &a[i][j]);
            if (a[i][j] != 0) {
                b[t] = a[i][j];
                t++;
            } else {
                pos_i = i;
            }
        }
    }
    pos = n - pos_i;
    int ni_xu = 0;
    for (int i = 0; i < len; i++) {
        for (int j = i + 1; j < len; j++) {
            if (b[i] > b[j]) {
                ni_xu++;
            }
        }
    }
    if (m % 2 == 0) {
        if ((ni_xu + pos) % 2 == 1) {
            printf("YES");
        } else
            printf("NO");
    } else {
        if (ni_xu % 2 == 0) {
            printf("YES");
        } else
            printf("NO");
    }
    free(b);
    free(a);
    return 0;
}
子任务 #1
Time Limit Exceeded
得分:70
测试点 #1
Accepted
得分:100
用时:2 ms
内存:196 KiB

输入文件(test1.in

3 3
1 2 6 
7 3 8 
0 4 5 

答案文件(test1.out

YES

用户输出

YES

系统信息

Exited with return code 0
测试点 #2
Accepted
得分:100
用时:2 ms
内存:308 KiB

输入文件(test2.in

3 3
7 1 5 
6 0 2 
3 4 8 

答案文件(test2.out

YES

用户输出

YES

系统信息

Exited with return code 0
测试点 #3
Accepted
得分:100
用时:2 ms
内存:196 KiB

输入文件(test3.in

4 4
13 11 1 9 
15 2 14 7 
0 10 3 8 
4 5 6 12 

答案文件(test3.out

YES

用户输出

YES

系统信息

Exited with return code 0
测试点 #4
Accepted
得分:100
用时:2 ms
内存:192 KiB

输入文件(test4.in

4 4
14 3 9 8 
4 15 5 0 
1 2 6 7 
10 11 12 13 

答案文件(test4.out

NO

用户输出

NO

系统信息

Exited with return code 0
测试点 #5
Accepted
得分:100
用时:2 ms
内存:196 KiB

输入文件(test5.in

4 4
9 13 2 5 
1 14 12 0 
3 4 10 7 
8 6 11 15 

答案文件(test5.out

NO

用户输出

NO

系统信息

Exited with return code 0
测试点 #6
Accepted
得分:100
用时:9 ms
内存:276 KiB

输入文件(test6.in

100 100
7690 5682 2677 2004 5559 6119 4307 2035 8893 7862 9155 2640 4139 6211 1754 6042 8035 8694 1
<48999 bytes omitted>

答案文件(test6.out

YES

用户输出

YES

系统信息

Exited with return code 0
测试点 #7
Accepted
得分:100
用时:9 ms
内存:328 KiB

输入文件(test7.in

100 100
7131 5702 6393 2569 6232 2219 5826 1730 3120 8643 4870 8412 4828 9339 2366 738 5908 5688 52
<48999 bytes omitted>

答案文件(test7.out

NO

用户输出

NO

系统信息

Exited with return code 0
测试点 #8
Time Limit Exceeded
得分:0
用时:3045 ms
内存:8076 KiB

输入文件(test8.in

1000 1000
852093 582459 126709 111945 392720 997041 498864 532066 280215 433547 734819 780448 18612
<6890801 bytes omitted>

答案文件(test8.out

YES
测试点 #9
Time Limit Exceeded
得分:0
用时:3004 ms
内存:8108 KiB

输入文件(test9.in

1000 1000
425610 18558 726158 634073 689595 11109 521599 44245 742153 819901 371590 568407 886681 3
<6890801 bytes omitted>

答案文件(test9.out

YES
测试点 #10
Time Limit Exceeded
得分:0
用时:3045 ms
内存:4484 KiB

输入文件(test10.in

587 931
402769 239103 45894 99675 444353 214471 33158 331145 254043 429952 47540 544790 544051 3134
<3715452 bytes omitted>

答案文件(test10.out

YES