Submission #1222177

#TimeUsernameProblemLanguageResultExecution timeMemory
1222177kargneqComparing Plants (IOI20_plants)C++20
0 / 100
0 ms328 KiB
#include <bits/stdc++.h>
using namespace std;

vector<int> r;
int n;

void init(int k, std::vector<int> rr) {
    r = rr;
    n = r.size();
}

int compare_plants(int x, int y) {
    // For k = 2, check if y is one of the next two plants after x
    int n1 = (x + 1) % n;
    int n2 = (x + 2) % n;
    if (r[x] == 0 && (y == n1 || y == n2)) return 1;  // x is definitely taller
    if (r[x] == 2 && (y == n1 || y == n2)) return -1; // x is definitely shorter

    // Check if x is one of the next two plants after y
    int yn1 = (y + 1) % n;
    int yn2 = (y + 2) % n;
    if (r[y] == 0 && (x == yn1 || x == yn2)) return -1; // y is definitely taller
    if (r[y] == 2 && (x == yn1 || x == yn2)) return 1;  // y is definitely shorter

    return 0; // inconclusive
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...