답안 #200074

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
200074 2020-02-05T09:07:14 Z SamAnd Coins (LMIO19_monetos) C++17
15.0758 / 100
98 ms 888 KB
#include <bits/stdc++.h>
using namespace std;
const int N = 302;

mt19937 rnd(134321);

int t, n, k1, k2;
int a[N][N];

int main()
{
    scanf("%d%d%d%d", &t, &n, &k1, &k2);
    for (int i = 1; i <= n; ++i)
    {
        for (int j = 1; j <= n; ++j)
            scanf("%d", &a[i][j]);
    }
    while (1)
    {
        bool z = false;
        if (rnd() % 2)
        {
            for (int i = 1; i <= n; ++i)
            {
                for (int j = 1; j < n; ++j)
                {
                    if (a[i][j] == 1 && a[i][j + 1] == 0)
                    {
                        z = true;
                        swap(a[i][j], a[i][j + 1]);
                    }
                }
            }
            for (int j = 1; j <= n; ++j)
            {
                for (int i = 1; i < n; ++i)
                {
                    if (a[i][j] == 1 && a[i + 1][j] == 0)
                    {
                        z = true;
                        swap(a[i][j], a[i + 1][j]);
                    }
                }
            }
        }
        else
        {
            for (int j = 1; j <= n; ++j)
            {
                for (int i = 1; i < n; ++i)
                {
                    if (a[i][j] == 1 && a[i + 1][j] == 0)
                    {
                        z = true;
                        swap(a[i][j], a[i + 1][j]);
                    }
                }
            }
            for (int i = 1; i <= n; ++i)
            {
                for (int j = 1; j < n; ++j)
                {
                    if (a[i][j] == 1 && a[i][j + 1] == 0)
                    {
                        z = true;
                        swap(a[i][j], a[i][j + 1]);
                    }
                }
            }
        }
        if (!z)
            break;
    }
    for (int i = 1; i <= n; ++i)
    {
        for (int j = 1; j <= n; ++j)
        {
            printf("%d ", a[i][j]);
        }
        printf("\n");
    }
    return 0;
}

Compilation message

monetos.cpp: In function 'int main()':
monetos.cpp:12:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d%d%d", &t, &n, &k1, &k2);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
monetos.cpp:16:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf("%d", &a[i][j]);
             ~~~~~^~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 376 KB K = 21
2 Incorrect 6 ms 376 KB K = 631
3 Partially correct 86 ms 888 KB K = 20178
4 Partially correct 97 ms 888 KB K = 23454
5 Partially correct 80 ms 888 KB K = 17863
6 Partially correct 88 ms 888 KB K = 21718
7 Partially correct 84 ms 888 KB K = 22415
8 Incorrect 79 ms 888 KB K = 21787
9 Incorrect 89 ms 888 KB K = 22109
10 Partially correct 98 ms 888 KB K = 22443