Submission #430666

# Submission time Handle Problem Language Result Execution time Memory
430666 2021-06-16T18:08:34 Z Ozy Comparing Plants (IOI20_plants) C++17
5 / 100
101 ms 8900 KB
#include "plants.h"
#include <bits/stdc++.h>
using namespace std;
#define lli int
#define rep(i,a,b) for (lli i = (a); i <= (b); i++)
#define repa(i,a,b) for (lli i = (a); i >= (b); i--)
#define debug(a) cout << #a << " = " << a << endl;
#define debugsl(a) cout << #a << " = " << a << ", ";

#define MAX 200000

lli n,pos;
lli pm[MAX+2];
vector<int> sig;

lli recurcion(lli pos, lli i) {

    lli y = pos;
    pos++;
    if (pos >= n) pos = 0;

    if (sig[pos] == sig[i]) {
        pm[y] = recurcion(pos,i);
        return pm[y];
    }
    else {
        pm[y] = pos;
        return pos;
    }
}

void init(int k, std::vector<int> r) {

	n = r.size();
	sig = vector<int> (n, 0);
    rep(i,0,n-1) {
        pm[i] = -1;
        sig[i] = r[i];
    }

    rep(i,0,n-1) if (pm[i] == -1) pm[i] = recurcion(i,i);

}

int compare_plants(int x, int y) {

	lli res;
	if (x > y) {
        swap(x,y);
        res = -1;
    }
    else res = 1;

	if (pm[x] >= y || pm[x] < x) {
        if (sig[x] == 1) res *= -1;
	}
	else if (pm[y] >= x && pm[y] < y) {
        if (sig[y] == 0) res *= -1;
	}
	else return 0;

	return res;

}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 280 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 67 ms 3032 KB Output is correct
7 Correct 79 ms 3344 KB Output is correct
8 Correct 101 ms 5736 KB Output is correct
9 Correct 101 ms 5748 KB Output is correct
10 Correct 96 ms 5844 KB Output is correct
11 Correct 93 ms 6224 KB Output is correct
12 Correct 99 ms 7400 KB Output is correct
13 Correct 96 ms 8788 KB Output is correct
14 Correct 90 ms 8900 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Incorrect 1 ms 204 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Incorrect 1 ms 204 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 1 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Incorrect 1 ms 204 KB Output isn't correct
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 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Incorrect 1 ms 204 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 280 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 67 ms 3032 KB Output is correct
7 Correct 79 ms 3344 KB Output is correct
8 Correct 101 ms 5736 KB Output is correct
9 Correct 101 ms 5748 KB Output is correct
10 Correct 96 ms 5844 KB Output is correct
11 Correct 93 ms 6224 KB Output is correct
12 Correct 99 ms 7400 KB Output is correct
13 Correct 96 ms 8788 KB Output is correct
14 Correct 90 ms 8900 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Incorrect 1 ms 204 KB Output isn't correct
18 Halted 0 ms 0 KB -