답안 #457690

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
457690 2021-08-07T09:52:30 Z idas Coins (LMIO19_monetos) C++11
12.0957 / 100
603 ms 812 KB
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin); i<(end); i++)
#define F first
#define S second
#define PB push_back
#define FAST_IO ios_base::sync_with_stdio(0); cin.tie(nullptr)

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef map<int, int> mii;


const int N=310;
int ts, n, k1, k2, g[N][N];

int gg[N][N];

void g1()
{
    FOR(i, 3, 10)
    {
        FOR(j, 3, 10)
        {
            gg[i][j]=1;
        }
    }

    gg[9][2]=1;
    FOR(i, 0, 10)
    {
        FOR(j, 0, 10)
        {
            cout << gg[i][j] << " ";
        }
        cout << '\n';
    }
}

int main()
{
    FAST_IO;
    cin >> ts >> n >> k1 >> k2;
    vector<pair<int, pii>> inf;
    FOR(i, 0, n)
    {
        FOR(j, 0, n)
        {
            cin >> g[i][j];
        }
    }

    bool going=true;
    int in=0;
    while(going){
        going=false;
        FOR(i, 0, n)
        {
            FOR(j, 0, n)
            {
                if(g[i][j]==0) continue;
                if(in&1){
                    if(i+1<=n-1 && g[i+1][j]==0){
                        swap(g[i][j], g[i+1][j]);
                        going=true;
                    }
                    else if(j+1<=n-1 && g[i][j+1]==0){
                        swap(g[i][j], g[i][j+1]);
                        going=true;
                    }
                }
                else{
                    if(j+1<=n-1 && g[i][j+1]==0){
                        swap(g[i][j], g[i][j+1]);
                        going=true;
                    }
                    else if(i+1<=n-1 && g[i+1][j]==0){
                        swap(g[i][j], g[i+1][j]);
                        going=true;
                    }
                }
                in++;
            }
        }
    }

    if(ts==1){
        g1();
        return 0;
    }

    FOR(i, 0, n)
    {
        FOR(j, 0, n)
        {
            cout << g[i][j] << " ";
        }
        cout << '\n';
    }
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 332 KB K = 28
2 Incorrect 1 ms 332 KB K = 611
3 Partially correct 88 ms 808 KB K = 19773
4 Partially correct 218 ms 800 KB K = 23138
5 Incorrect 89 ms 808 KB K = 20561
6 Partially correct 142 ms 796 KB K = 22293
7 Partially correct 164 ms 808 KB K = 22451
8 Incorrect 155 ms 812 KB K = 26189
9 Incorrect 156 ms 796 KB K = 22186
10 Partially correct 603 ms 796 KB K = 21747