제출 #1242101

#제출 시각아이디문제언어결과실행 시간메모리
1242101mychecksedad메시지 (IOI24_message)C++20
컴파일 에러
0 ms0 KiB
#include "message.h"
#include <bits/stdc++.h>
using namespace std;
#include <cassert>
#include <cstdio>
#include <cstdlib>

namespace {
const int PACKET_SIZE = 31;
const int CALLS_CNT_LIMIT = 100;

int calls_cnt;
std::vector<bool> C(PACKET_SIZE);
std::vector<std::vector<bool>> R;

void quit(const char* message) {
  printf("%s\n", message);
  exit(0);
}

void run_scenario() {
  R.clear();
  calls_cnt = 0;

  int S;
  assert(1 == scanf("%d", &S));
  std::vector<bool> M(S);
  for (int i = 0; i < S; i++) {
    int bit;
    assert(1 == scanf("%d", &bit));
    assert((bit == 0) || (bit == 1));
    M[i] = bit;
  }

  for (int i = 0; i < PACKET_SIZE; i++) {
    int bit;
    assert(1 == scanf("%d", &bit));
    assert((bit == 0) || (bit == 1));
    C[i] = bit;
  }

  send_message(M, C);
  std::vector<bool> D = receive_message(R);

  int K = (int)R.size();
  int L = (int)D.size();
  for(int i = 0; i < S; ++i) assert(D[i] == M[i]);
  printf("%d %d\n", K, L);
  for (int i = 0; i < L; i++)
    printf("%s%d", (i == 0 ? "" : " "), (D[i] ? 1 : 0));
  printf("\n");
}

std::vector<bool> taint(const std::vector<bool>& A) {
  std::vector<bool> B = A;
  bool bit = 0;
  for (int i = 0; i < PACKET_SIZE; i++)
    if (C[i] == 1) {
      B[i] = bit;
      bit = !bit;
    }
  return B;
}

} // namespace

std::vector<bool> send_packet(std::vector<bool> A) {
  calls_cnt++;
  if (calls_cnt > CALLS_CNT_LIMIT)
    quit("Too many calls");
  if ((int)A.size() != PACKET_SIZE)
    quit("Invalid argument");

  for(int x: A) cerr << x <<  ' ';
    cerr << '\n';
  std::vector<bool> B = taint(A);
  R.push_back(B);
  return B;
}

int main() {
  int T;
  assert(1 == scanf("%d", &T));
  for (int i = 1; i <= T; i++)
    run_scenario();
}

컴파일 시 표준 에러 (stderr) 메시지

/usr/bin/ld: /tmp/ccTarNj3.o: in function `send_packet(std::vector<bool, std::allocator<bool> >)':
stub.cpp:(.text+0x250): multiple definition of `send_packet(std::vector<bool, std::allocator<bool> >)'; /tmp/cctU8U0D.o:message.cpp:(.text+0x690): first defined here
/usr/bin/ld: /tmp/ccTarNj3.o: in function `main':
stub.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/cctU8U0D.o:message.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/cctU8U0D.o: in function `(anonymous namespace)::run_scenario()':
message.cpp:(.text+0x162): undefined reference to `send_message(std::vector<bool, std::allocator<bool> >, std::vector<bool, std::allocator<bool> >)'
/usr/bin/ld: message.cpp:(.text+0x244): undefined reference to `receive_message(std::vector<std::vector<bool, std::allocator<bool> >, std::allocator<std::vector<bool, std::allocator<bool> > > >)'
/usr/bin/ld: /tmp/ccTarNj3.o: in function `(anonymous namespace)::run_decoder()':
stub.cpp:(.text+0x6a1): undefined reference to `receive_message(std::vector<std::vector<bool, std::allocator<bool> >, std::allocator<std::vector<bool, std::allocator<bool> > > >)'
/usr/bin/ld: /tmp/ccTarNj3.o: in function `(anonymous namespace)::run_encoder()':
stub.cpp:(.text+0xc33): undefined reference to `send_message(std::vector<bool, std::allocator<bool> >, std::vector<bool, std::allocator<bool> >)'
collect2: error: ld returned 1 exit status