Submission #1061950

# Submission time Handle Problem Language Result Execution time Memory
1061950 2024-08-16T15:54:11 Z MilosMilutinovic A Light Inconvenience (CEOI23_light) C++17
0 / 100
1 ms 440 KB
#include "light.h"
#include <bits/stdc++.h>

using namespace std;

long long n;

bool on[5005];
bool new_on[5005];

void prepare() {
  n = 1;
  on[1] = true;
}

pair<long long, vector<long long>> join(long long p) {
  n += p;
  int lst = -p;
  for (int i = 1; i <= n; i++) {
    if (on[i]) {
      lst = i;
    }
    new_on[i] = (i - lst < p);
  }
  for (int i = 1; i <= n; i++) {
    on[i] = new_on[i];
  }
  vector<long long> ids(1, n);
  while (true) {
    int i = ids.back();
    int idx = -1;
    int len = n - i + 1;
    for (int j = max(1, i - len - 1); j < i; j++) {
      if (on[j]) {
        idx = j;
        break;
      }
    }
    if (idx == -1) {
      break;
    }
    ids.push_back(idx);
  }
  ids.push_back(1);
  for (int i = 1; i <= n; i++) {
    on[i] = false;
  }
  for (int i : ids) {
    on[i] = true;
  }
  sort(ids.begin(), ids.end());
  ids.erase(unique(ids.begin(), ids.end()), ids.end());
	return {p, ids};
}

pair<long long, vector<long long>> leave(long long p) {
  for (int i = n - p + 1; i <= n; i++) {
    on[i] = false;
  }
  n -= p;
  int lst = -p;
  for (int i = 1; i <= n; i++) {
    if (on[i]) {
      lst = i;
    }
    new_on[i] = (i - lst < p);
  }
  for (int i = 1; i <= n; i++) {
    on[i] = new_on[i];
  }
  vector<long long> ids(1, n);
  while (true) {
    int i = ids.back();
    int idx = -1;
    int len = n - i + 1;
    for (int j = max(1, i - len - 1); j < i; j++) {
      if (on[j]) {
        idx = j;
        break;
      }
    }
    if (idx == -1) {
      break;
    }
    ids.push_back(idx);
  }
  ids.push_back(1);
  for (int i = 1; i <= n; i++) {
    on[i] = false;
  }
  for (int i : ids) {
    on[i] = true;
  }
  sort(ids.begin(), ids.end());
  ids.erase(unique(ids.begin(), ids.end()), ids.end());
  return {p, ids};
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Correct
2 Runtime error 1 ms 344 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Correct
2 Incorrect 0 ms 344 KB Not correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Correct
2 Incorrect 0 ms 344 KB Not correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Correct
2 Incorrect 0 ms 344 KB Not correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Correct
2 Incorrect 0 ms 344 KB Not correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Correct
2 Incorrect 0 ms 344 KB Not correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Correct
2 Runtime error 0 ms 440 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -