Submission #200073

# Submission time Handle Problem Language Result Execution time Memory
200073 2020-02-05T09:05:34 Z SamAnd Coins (LMIO19_monetos) C++17
0 / 100
2000 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][j + 1]);
                    }
                }
            }
        }
        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][j + 1]);
                    }
                }
            }
            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]);
             ~~~~~^~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Execution timed out 2081 ms 376 KB Time limit exceeded
2 Execution timed out 2062 ms 376 KB Time limit exceeded
3 Execution timed out 2085 ms 888 KB Time limit exceeded
4 Execution timed out 2082 ms 888 KB Time limit exceeded
5 Execution timed out 2072 ms 760 KB Time limit exceeded
6 Execution timed out 2073 ms 888 KB Time limit exceeded
7 Execution timed out 2083 ms 888 KB Time limit exceeded
8 Execution timed out 2076 ms 888 KB Time limit exceeded
9 Execution timed out 2069 ms 760 KB Time limit exceeded
10 Execution timed out 2079 ms 888 KB Time limit exceeded