Submission #300601

# Submission time Handle Problem Language Result Execution time Memory
300601 2020-09-17T10:16:03 Z CodePlatina Comparing Plants (IOI20_plants) C++14
0 / 100
6 ms 768 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;
        }
        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 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Runtime error 6 ms 640 KB Execution killed with signal 11
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Runtime error 4 ms 640 KB Execution killed with signal 11
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Runtime error 4 ms 640 KB Execution killed with signal 11
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Runtime error 4 ms 768 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Runtime error 4 ms 640 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 416 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Runtime error 4 ms 640 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Runtime error 6 ms 640 KB Execution killed with signal 11
5 Halted 0 ms 0 KB -