제출 #630717

#제출 시각아이디문제언어결과실행 시간메모리
630717jwvg0425죄수들의 도전 (IOI22_prison)C++17
컴파일 에러
0 ms0 KiB
#include "prison.h" #include <cassert> #include <cstdio> #include <string> #include <vector> static constexpr int kNumPrisoners = 500; static void invalid_strategy(std::string message) { printf("%s\n", message.c_str()); exit(0); } int main() { int N; assert(1 == scanf("%d", &N)); std::vector<std::vector<int>> strategy = devise_strategy(N); if (strategy.size() == 0) { invalid_strategy("s is an empty array"); } int x = strategy.size() - 1; for (int i = 0; i <= x; ++i) { if (static_cast<int>(strategy[i].size()) != N + 1) { invalid_strategy("s[i] contains incorrect length"); } if (strategy[i][0] < 0 || strategy[i][0] > 1) { invalid_strategy("First element of s[i] is non-binary"); } for (int j = 1; j <= N; ++j) { if (strategy[i][j] < -2 || strategy[i][j] > x) { invalid_strategy("s[i][j] contains incorrect value"); } } } FILE *log_file = fopen("log.txt","w"); int A, B; while (1 == scanf("%d", &A) && A != -1) { assert(1 == scanf("%d", &B)); bool answer = false; int whiteboard = 0; for (int i = 0; i < kNumPrisoners && !answer; ++i) { int check = strategy[whiteboard][0]; whiteboard = strategy[whiteboard][check == 0 ? A : B]; if (whiteboard < 0) { answer = true; printf("%c\n", "BA"[whiteboard + 2]); } else { if (i > 0) { fprintf(log_file, " "); } fprintf(log_file, "%d", whiteboard); } } if (!answer) { printf("X\n"); } fprintf(log_file, "\n"); fflush(log_file); } }

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

/usr/bin/ld: /tmp/cc2pt0aO.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccDLpwON.o:prison.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccDLpwON.o: in function `main':
prison.cpp:(.text.startup+0x51): undefined reference to `devise_strategy(int)'
/usr/bin/ld: /tmp/cc2pt0aO.o: in function `main':
grader.cpp:(.text.startup+0x194): undefined reference to `devise_strategy(int)'
collect2: error: ld returned 1 exit status