Submission #622343

# Submission time Handle Problem Language Result Execution time Memory
622343 2022-08-04T07:38:42 Z happypotato Comparing Plants (IOI20_plants) C++17
0 / 100
1 ms 212 KB
#include "plants.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int, int>
#define ff first
#define ss second
#define pb push_back
vector<int> r;
int n, k;
int st;
void st1init();
void init(int K, vector<int> R) {
    n = R.size(); k = K; r = R;
    if (k == 2) {
        st = 1;
        st1init();
    }
	return;
}
vector<int> st1ps;
void st1init() {
    st1ps.resize(n);
    st1ps[0] = r[0];
    for (int i = 1; i < n; i++) {
        st1ps[i] = st1ps[i - 1] + r[i];
    }
}
int st1psquery(int l, int r) {
    if (l > r) return st1psquery(r, n - 1) + st1psquery(0, l);
    return (st1ps[r] - (l == 0 ? 0 : st1ps[l - 1]));
}
int st1query(int l, int r) {
    int diff = r - l;
    int ret1 = st1psquery(r - 1, l), ret2 = st1psquery(r, l - 1);
    if (ret1 == diff || ret2 == n - diff) return 1;
    else if (ret1 == 0 || ret2 == 0) return -1;
    else return 0;
}
int compare_plants(int x, int y) {
    if (st == 1) return st1query(x, y);
}

Compilation message

plants.cpp: In function 'int compare_plants(int, int)':
plants.cpp:42:1: warning: control reaches end of non-void function [-Wreturn-type]
   42 | }
      | ^
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -