Submission #300613

# Submission time Handle Problem Language Result Execution time Memory
300613 2020-09-17T10:27:30 Z CodePlatina Comparing Plants (IOI20_plants) C++14
0 / 100
1 ms 256 KB
#include "plants.h"
#include <iostream>

using namespace std;

int N, K;
bool arr[5050][5050];

void init(int k, vector<int> r)
{
	N = r.size(); K = k;
	for(int i = 0; i < N; ++i)
    {
        int cnt = 0, tar = -1;
        for(int j = 0; j < K - 1; ++j) if(r[j] == 0) ++cnt;
        for(int j = K - 1; j < N; ++j)
        {
            if(cnt == 0 && r[j] == 0) { tar = j; break; }
            if(r[j] == 0) ++cnt;
            if(r[j - K + 1] == 0) --cnt;
        }
        if(tar == -1) for(int j = 0; j < K - 1; ++j)
        {
            if(cnt == 0 && r[j] == 0) { tar = j; break; }
            if(r[j] == 0) ++cnt;
            if(r[N + j - K + 1] == 0) --cnt;
        }

        r[tar] = -1;
        for(int j = 1; j < K; ++j)
        {
            int t = tar + j; if(t >= N) t -= N;
            if(r[t] != -1) arr[tar][t] = true;

            t = tar - j; if(t < 0) t += N;
            if(r[t] != -1) --r[t], arr[tar][t] = true;
        }
    }

    for(int i = 0; i < N; ++i)
    {
        for(int j = 0; j < N; ++j)
        {
            for(int k = 0; k < N; ++k)
            {
                if(arr[j][i] && arr[i][k]) arr[j][k] = true;
            }
        }
    }

    for(int i = 0; i < N; ++i)
    {
        for(int j = 0; j < N; ++j)
        {
            cout << arr[i][j];
        }
        cout << endl;
    }
}

int compare_plants(int x, int y)
{
	if(arr[x][y]) return 1;
	else if(arr[y][x]) return -1;
	return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -