답안 #708694

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
708694 2023-03-12T07:58:57 Z ntdxl05 Ancient Machine (JOI21_ancient_machine) C++17
5 / 100
44 ms 2656 KB
#include <bits/stdc++.h>
#include "Anna.h"
#include <vector>
using namespace std;

namespace {

int variable_example = 0;

}

void Anna(int N, std::vector<char> S) {
const int dc[] = {'X', 'Y', 'Z'};
int idc[256];
  for (int i = 0; i < 3; i++) idc[dc[i]] = i;
  if (N <= 18) {
    for (int i = 0; i < N; i++) {
      Send(idc[S[i]] >> 1 & 1);
      Send(idc[S[i]] & 1);
    }
    return ;
  }
}
#include <bits/stdc++.h>
#include "Bruno.h"
#include <vector>

using namespace std;

namespace {

// int variable_example = 0;

const int inf = 1e9;

int FunctionExample(int P) { return 1 - P; }

template<class U, class V>
bool minz(U &a, V b) {
  if (a > b) return a = b, 1;
  return 0;
}
template<class U, class V>
bool maxz(U &a, V b) {
  if (a < b) return a = b, 1;
  return 0;
}

}  // namespace

void Bruno(int N, int L, std::vector<int> A) {
const int dc[] = {'X', 'Y', 'Z'};
int idc[256];
  for (int i = 0; i < L; i++) {
    // variable_example += FunctionExample(A[i]);
  }

  vector<char> S(N);
  for (int i = 0; i < N; i++) S[i] = dc[A[i << 1] << 1 | A[i << 1 | 1]];
  vector<int> dp(1 << N, -inf), trc(1 << N, -1);
  dp[0] = 0;
  for (int msk = 0; msk < (1 << N) - 1; msk++) {
    vector<int> b(N);
    for (int i = 0; i < N; i++) b[i] = msk >> i & 1;
    for (int i = 0; i < N; i++) {
      if (b[i]) continue;
      int l = i - 1, r = i + 1;
      for (; ~l && !b[l]; l--);
      for (; r < N && !b[r]; r++);
      bool e = ~l && r < N && S[i] == 'Y' && S[l] == 'X' && S[r] == 'Z';
      if (maxz(dp[msk | 1 << i], dp[msk] + e)) trc[msk | 1 << i] = i;
    }
  }

  int cr = (1 << N) - 1;
  while (cr) {
    auto &t = trc[cr];
    Remove(t);
    cr ^= 1 << t;
  }
}

Compilation message

Anna.cpp: In function 'void Anna(int, std::vector<char>)':
Anna.cpp:18:20: warning: array subscript has type 'char' [-Wchar-subscripts]
   18 |       Send(idc[S[i]] >> 1 & 1);
      |                    ^
Anna.cpp:19:20: warning: array subscript has type 'char' [-Wchar-subscripts]
   19 |       Send(idc[S[i]] & 1);
      |                    ^
Anna.cpp: At global scope:
Anna.cpp:8:5: warning: '{anonymous}::variable_example' defined but not used [-Wunused-variable]
    8 | int variable_example = 0;
      |     ^~~~~~~~~~~~~~~~

Bruno.cpp: In function 'void Bruno(int, int, std::vector<int>)':
Bruno.cpp:30:5: warning: unused variable 'idc' [-Wunused-variable]
   30 | int idc[256];
      |     ^~~
Bruno.cpp: At global scope:
Bruno.cpp:13:5: warning: 'int {anonymous}::FunctionExample(int)' defined but not used [-Wunused-function]
   13 | int FunctionExample(int P) { return 1 - P; }
      |     ^~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 41 ms 2564 KB Output is correct
2 Correct 43 ms 2584 KB Output is correct
3 Correct 41 ms 2648 KB Output is correct
4 Correct 39 ms 2560 KB Output is correct
5 Correct 44 ms 2568 KB Output is correct
6 Correct 43 ms 2568 KB Output is correct
7 Correct 1 ms 608 KB Output is correct
8 Correct 2 ms 492 KB Output is correct
9 Correct 39 ms 2568 KB Output is correct
10 Correct 39 ms 2568 KB Output is correct
11 Correct 40 ms 2656 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 7 ms 1080 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -