답안 #543092

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
543092 2022-03-29T09:26:49 Z abc864197532 Ancient Machine (JOI21_ancient_machine) C++17
5 / 100
103 ms 8992 KB
#include "Anna.h"
#include <vector>

namespace {

int variable_example = 0;

}

void Anna(int N, std::vector<char> S) {
  for (int i = 0; i < N; i += 3) {
    int now = 0;
    for (int j = i; j < i + 3 && j < N; ++j)
      now = now * 3 + S[j] - 'X';
    for (int j = 4; ~j; --j)
      Send(now >> j & 1);
  }
}
#include "Bruno.h"
#include <vector>
#include <set>
#include <tuple>
#include <queue>
 
namespace {
 
int variable_example = 0;
 
int FunctionExample(int P) { return 1 - P; }
 
}  // namespace
 
void Bruno(int N, int L, std::vector<int> A) {
  std::vector <char> S(N);
  int pt = 0;
  for (int i = 0; i < L; i += 5) {
    int now = 0;
    for (int j = i; j < i + 5; ++j)
      now = now * 2 + A[j];
    if (pt + 1 == N)
      S[pt] = now + 'X';
    else if (pt + 2 == N) {
      S[pt] = now / 3 + 'X';
      S[pt + 1] = now % 3 + 'X';
    } else {
      S[pt] = now / 9 + 'X';
      S[pt + 1] = (now / 3) % 3 + 'X';
      S[pt + 2] = now % 3 + 'X';
    }
    pt += 3;
  }
  std::priority_queue <int> X;
  std::vector <std::pair <int, int>> Y;
  std::set <int> Se;
  for (int i = 0; i < N; ++i)
    Se.insert(i);
  for (int i = 0; i < N; ++i) {
    if (S[i] == 'X')
      X.push(i);
    else if (S[i] == 'Y' && !X.empty())
      Y.emplace_back(X.top(), i), X.pop();
    else if (S[i] == 'Z') {
      while (!Y.empty()) {
        int a, b; std::tie(a, b) = Y.back();
        std::vector <int> del;
        for (auto it = Se.lower_bound(a + 1); it != Se.end() && *it < b; ++it)
          Remove(*it), del.push_back(*it);
        for (auto it = Se.lower_bound(b + 1); it != Se.end() && *it < i; ++it)
          Remove(*it), del.push_back(*it);
        Remove(b), del.push_back(b);
        for (int i : del)
          Se.erase(i);
        Y.pop_back();
        X.push(a);
        while (!X.empty() && !Se.count(X.top()))
          X.pop();
        while (!Y.empty() && !Se.count(Y.back().first) && !Se.count(Y.back().second))
          Y.pop_back();
      }
      Remove(i), Se.erase(i);
    }
  }
  for (int i : Se)
    Remove(i);
}

Compilation message

Anna.cpp:6:5: warning: '{anonymous}::variable_example' defined but not used [-Wunused-variable]
    6 | int variable_example = 0;
      |     ^~~~~~~~~~~~~~~~

Bruno.cpp:11:5: warning: 'int {anonymous}::FunctionExample(int)' defined but not used [-Wunused-function]
   11 | int FunctionExample(int P) { return 1 - P; }
      |     ^~~~~~~~~~~~~~~
Bruno.cpp:9:5: warning: '{anonymous}::variable_example' defined but not used [-Wunused-variable]
    9 | int variable_example = 0;
      |     ^~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 516 KB Output is correct
2 Correct 0 ms 516 KB Output is correct
3 Correct 0 ms 516 KB Output is correct
4 Correct 0 ms 516 KB Output is correct
5 Correct 0 ms 516 KB Output is correct
6 Correct 0 ms 520 KB Output is correct
7 Correct 1 ms 512 KB Output is correct
8 Correct 0 ms 512 KB Output is correct
9 Correct 0 ms 512 KB Output is correct
10 Correct 0 ms 520 KB Output is correct
11 Correct 0 ms 588 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 103 ms 8992 KB Wrong Answer [6]
2 Halted 0 ms 0 KB -