Submission #447760

# Submission time Handle Problem Language Result Execution time Memory
447760 2021-07-27T13:16:35 Z dxz05 Dancing Elephants (IOI11_elephants) C++14
0 / 100
1 ms 304 KB
#include "elephants.h"
#include <bits/stdc++.h>

using namespace std;

const int MAXN = 2e5 + 3e2;

int N, L;
int X[MAXN];
int perm[MAXN];
void init(int _N, int _L, int _X[]){
    N = _N;
    L = _L;

    for (int i = 0; i < N; i++) {
        X[i] = _X[i];
        perm[i] = i;
    }

    sort(perm, perm + N, [](int i, int j){
        return X[i] < X[j];
    });

}

int update(int i, int y){
    X[i] = y;
    int j = i;
    while (j < N - 1 && X[perm[j]] > X[perm[j + 1]]){
        swap(perm[j], perm[j + 1]);
        j++;
    }

    j = i;
    while (j > 1 && X[perm[j]] < X[perm[j - 1]]){
        swap(perm[j], perm[j - 1]);
        j--;
    }

    for (j = 0; j < N; j++) cerr << X[perm[j]] << ' '; cerr << endl;

    int ans = 1, last = X[perm[0]];
    for (j = 0; j < N; j++){
        int x = X[perm[j]];
        if (x - last > L){
            ans++;
            last = x;
        }
    }

    return ans;
}

Compilation message

elephants.cpp: In function 'int update(int, int)':
elephants.cpp:40:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   40 |     for (j = 0; j < N; j++) cerr << X[perm[j]] << ' '; cerr << endl;
      |     ^~~
elephants.cpp:40:56: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   40 |     for (j = 0; j < N; j++) cerr << X[perm[j]] << ' '; cerr << endl;
      |                                                        ^~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 304 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 304 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 304 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 304 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 304 KB Output isn't correct
2 Halted 0 ms 0 KB -