Submission #421055

# Submission time Handle Problem Language Result Execution time Memory
421055 2021-06-08T16:56:31 Z Monchito Comparing Plants (IOI20_plants) C++14
5 / 100
94 ms 8652 KB
#include <iostream>
#include <vector>
using namespace std;

int K, N;
vector<int> R, pref;

void init(int k, vector<int> r){
    K = k;
    R = r;
    N = (int)r.size();

    pref = vector<int>(N+1, 0);
    for(int i=1; i<=N; i++) pref[i] = pref[i-1] + r[i-1];
}

int compare_plants(int x, int y){
    int sum = pref[y] - pref[x+1]; 

    //cout << "#### debug log: sum1 = " << sum << " #####\n";

    if(R[x] == 0 && sum == 0) return 1; 
    if(R[x] == 1 && sum == y-x-1) return -1;

    sum = pref[N] - pref[y+1] + pref[x];

    //cout << "#### debug log: sum2 = " << sum << " #####\n";

    if(R[y] == 0 && sum == 0) return -1;
    if(R[y] == 1 && sum == N-(y+1) + x) return 1;

    return 0;
}

/*
int main(){
    int n, k, q; cin >> n >> k >> q;
    vector<int> r(n);
    for(int i=0; i<n; i++) cin >> r[i];

    init(k, r);

    while(q--){
        int x, y; cin >> x >> y;
        cout << compare_plants(x, y) << endl;
    }

    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 0 ms 288 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 57 ms 4008 KB Output is correct
7 Correct 69 ms 5160 KB Output is correct
8 Correct 94 ms 8636 KB Output is correct
9 Correct 91 ms 8576 KB Output is correct
10 Correct 91 ms 8632 KB Output is correct
11 Correct 91 ms 8616 KB Output is correct
12 Correct 87 ms 8652 KB Output is correct
13 Correct 83 ms 8652 KB Output is correct
14 Correct 86 ms 8644 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 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 1 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 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Incorrect 0 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 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Incorrect 1 ms 292 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 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 288 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 57 ms 4008 KB Output is correct
7 Correct 69 ms 5160 KB Output is correct
8 Correct 94 ms 8636 KB Output is correct
9 Correct 91 ms 8576 KB Output is correct
10 Correct 91 ms 8632 KB Output is correct
11 Correct 91 ms 8616 KB Output is correct
12 Correct 87 ms 8652 KB Output is correct
13 Correct 83 ms 8652 KB Output is correct
14 Correct 86 ms 8644 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Incorrect 1 ms 204 KB Output isn't correct
18 Halted 0 ms 0 KB -