Submission #935906

# Submission time Handle Problem Language Result Execution time Memory
935906 2024-02-29T18:29:15 Z EJIC_B_KEDAX Comparing Plants (IOI20_plants) C++17
0 / 100
4000 ms 223452 KB
#include <bits/stdc++.h>
 
using ll = long long;
 
using namespace std;
 
const int N = 200200;
vector<int> g[N];
int used[N], tmp1[N], tmp2[N];
int clc[5050][5050];

void dfs(int s, int d) {
	clc[d][s] = 1;
	for (int i : g[s]) {
		if (!used[i]) {
			dfs(i, d);
		}
	}
}
 
void init(int k, vector<int> r) {
    int n = r.size();
    int ok = 0, last, lev = n, iter = 0;
    for (int i = 0; i < n; i++) {
    	tmp1[i] = -1;
    	tmp2[i] = -1;
    }
    while (ok < n) {
        last = -k;
        for (int i = n - 1; i > n - k; i--) {
            if (!r[i]) {
                last = i - n;
                break;
            }
        }
        vector<int> nw = r;
        for (int i = 0; i < n; i++) {
            if (!r[i]) {
                if (i - last >= k) {
                	if (tmp1[i] != -1) {
                		g[tmp1[i]].push_back(i);
                	}
                	if (tmp2[i] != -1) {
                		g[tmp2[i]].push_back(i);
                	}
                    ok++;
                    for (int j = i - 1; j > i - k; j--) {
                        if (j >= 0) {
                            nw[j]--;
                            tmp1[j] = i;
                        } else {
                            nw[j + n]--;
                            tmp1[j + n] = i;
                        }
                    }
                    for (int j = i + 1; j < i + k; j++) {
                        if (j < n) {
                            tmp2[j] = i;
                        } else {
                            tmp2[j - n] = i;
                        }
                    }
                    nw[i] = INT32_MAX / 2;
                }
                last = i;
            }
        }
        swap(nw, r);
        lev--;
        iter++;
        assert(iter < n + 10);
    }
    for (int i = 0; i < n; i++) {
    	for (int j = 0; j < n; j++) {
    		used[j] = 0;
    	}
    	dfs(i, i);
    }
}
 
int compare_plants(int x, int y) {
    if (clc[y][x]) {
        return -1;
    }
    return clc[x][y];
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 8540 KB Output is correct
2 Correct 1 ms 8540 KB Output is correct
3 Correct 1 ms 8540 KB Output is correct
4 Correct 1 ms 8540 KB Output is correct
5 Correct 2 ms 10588 KB Output is correct
6 Correct 40 ms 13376 KB Output is correct
7 Runtime error 178 ms 223452 KB Execution killed with signal 11
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 8536 KB Output is correct
2 Correct 2 ms 8540 KB Output is correct
3 Correct 2 ms 8536 KB Output is correct
4 Correct 2 ms 8536 KB Output is correct
5 Execution timed out 4022 ms 8536 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 8536 KB Output is correct
2 Correct 2 ms 8540 KB Output is correct
3 Correct 2 ms 8536 KB Output is correct
4 Correct 2 ms 8536 KB Output is correct
5 Execution timed out 4022 ms 8536 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 8540 KB Output is correct
2 Correct 2 ms 10588 KB Output is correct
3 Execution timed out 4075 ms 29640 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 8536 KB Output is correct
2 Correct 2 ms 8536 KB Output is correct
3 Correct 2 ms 8540 KB Output is correct
4 Correct 2 ms 8540 KB Output is correct
5 Correct 2 ms 10584 KB Output is correct
6 Correct 3 ms 10588 KB Output is correct
7 Correct 13 ms 15324 KB Output is correct
8 Execution timed out 4009 ms 9048 KB Time limit exceeded
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 8536 KB Output is correct
2 Correct 1 ms 8792 KB Output is correct
3 Correct 2 ms 8540 KB Output is correct
4 Correct 2 ms 10588 KB Output is correct
5 Execution timed out 4078 ms 8676 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 8540 KB Output is correct
2 Correct 1 ms 8540 KB Output is correct
3 Correct 1 ms 8540 KB Output is correct
4 Correct 1 ms 8540 KB Output is correct
5 Correct 2 ms 10588 KB Output is correct
6 Correct 40 ms 13376 KB Output is correct
7 Runtime error 178 ms 223452 KB Execution killed with signal 11
8 Halted 0 ms 0 KB -