Submission #393010

# Submission time Handle Problem Language Result Execution time Memory
393010 2021-04-22T14:12:38 Z phathnv Comparing Plants (IOI20_plants) C++11
11 / 100
4000 ms 2097156 KB
#include <bits/stdc++.h>
#include "plants.h"

using namespace std;

vector<vector<bool>> d;

void init(int k, std::vector<int> r) {
    int n = r.size();
    vector<int> p(n, -1);
    d.assign(n, vector<bool>(n, 0));
    for(int val = n - 1; val >= 0; val--){
        for(int i = 0; i < n; i++){
            if (r[i] || r[i] == -1)
                continue;
            bool ok = 1;
            for(int j = 1; j < k; j++)
                ok &= (r[(i - j + n) % n] != 0);
            if (ok){
                p[i] = val;
                for(int j = 1; j < k; j++){
                    if (r[(i - j + n) % n] != -1){
                        r[(i - j + n) % n]--;
                        d[i][(i - j + n) % n] = 1;
                    }
                    if (r[(i + j) % n] != -1)
                        d[i][(i + j) % n] = 1;
                }
                r[i] = -1;
                break;
            }
        }
    }

    for(int k = 0; k < n; k++)
        for(int i = 0; i < n; i++)
            for(int j = 0; j < n; j++)
                d[i][j] = d[i][j] || (d[i][k] && d[k][j]);

	return;
}

int compare_plants(int x, int y) {
    if (d[x][y])
        return 1;
    if (d[y][x])
        return -1;
	return 0;
}

Compilation message

plants.cpp: In function 'void init(int, std::vector<int>)':
plants.cpp:35:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   35 |     for(int k = 0; k < n; k++)
      |     ^~~
plants.cpp:40:2: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   40 |  return;
      |  ^~~~~~
plants.cpp: In function 'int compare_plants(int, int)':
plants.cpp:46:5: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   46 |     if (d[y][x])
      |     ^~
plants.cpp:48:2: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   48 |  return 0;
      |  ^~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 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 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 58 ms 4032 KB Output is correct
7 Execution timed out 4046 ms 54940 KB Time limit exceeded
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 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 Correct 1 ms 204 KB Output is correct
5 Correct 5 ms 204 KB Output is correct
6 Execution timed out 4088 ms 460 KB Time limit exceeded
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 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 Correct 1 ms 204 KB Output is correct
5 Correct 5 ms 204 KB Output is correct
6 Execution timed out 4088 ms 460 KB Time limit exceeded
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Execution timed out 4091 ms 4932 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 300 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 5 ms 332 KB Output is correct
7 Correct 97 ms 1180 KB Output is correct
8 Correct 128 ms 1164 KB Output is correct
9 Correct 100 ms 1172 KB Output is correct
10 Correct 126 ms 1172 KB Output is correct
11 Correct 97 ms 1224 KB Output is correct
12 Correct 101 ms 1172 KB Output is correct
13 Correct 125 ms 1172 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 292 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 3829 ms 484 KB Output is correct
6 Runtime error 1072 ms 2097156 KB Execution killed with signal 9
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 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 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 58 ms 4032 KB Output is correct
7 Execution timed out 4046 ms 54940 KB Time limit exceeded
8 Halted 0 ms 0 KB -