Submission #447760

#TimeUsernameProblemLanguageResultExecution timeMemory
447760dxz05Dancing Elephants (IOI11_elephants)C++14
0 / 100
1 ms304 KiB
#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 (stderr)

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 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...