제출 #988354

#제출 시각아이디문제언어결과실행 시간메모리
988354Muaath_5동굴 (IOI13_cave)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int, int>
using namespace std;

const int N = 2e5+1;

#ifndef MUAATH_5
#include "cave.h"
#endif

int tryCombination(int c[]);

void answer(int s[], int d[]);

void exploreCave(int n) {
	int sure[n] = {};
	int correct[n] = {};
	int index[n] = {};
	for (int i = 0; i < n; i++) {
		int open = (tryCombination(correct) == i ? 1 : 0);
		int l = 0, r = n-1;
		while (l < r) {
			const int mid = (l+r)/2;
			int cpy[n];
			for (int i = 0; i < n; i++)
				cpy[i] = correct[i];
			if (!open) {
				for (int i = mid+1; i < n; i++)
					if (!sure[i])				
						cpy[i] = 1;
			}
			else {
				for (int i = 0; i <= mid; i++)
					if (!sure[i])
						cpy[i] = 1;
			}
			if (tryCombination(cpy) == i)
				l = mid+1;
			else
				r = mid;
		} 
		index[i] = l;
		correct[l] = open;
		sure[l] = 1;
	}
	int idx[n] = {};
	for (int i = 0; i < n; i++)
		idx[index[i]] = i;
	answer(correct, idx);
} 

#include <stdio.h>
#include <stdlib.h>

#define MAX_N 5000
#define MAX_CALLS 70000

#define fail(s, x...) do { \
		fprintf(stderr, s "\n", ## x); \
		exit(1); \
	} while(0)

/* Symbol obfuscation */
#define N koala
#define realS kangaroo
#define realD possum
#define inv platypus
#define num_calls echidna

static int N;
static int realS[MAX_N];
static int realD[MAX_N];
static int inv[MAX_N];
static int num_calls;

void answer(int S[], int D[]) {
    int i;
    int correct = 1;
    for (i = 0; i < N; ++i)
        if (S[i] != realS[i] || D[i] != realD[i]) {
            correct = 0;
            break;
        }

    if (correct)
        printf("CORRECT\n");
    else
        printf("INCORRECT\n");

    for (i = 0; i < N; ++i) {
        if (i > 0)
            printf(" ");
        printf("%d", S[i]);
    }
    printf("\n");

    for (i = 0; i < N; ++i) {
        if (i > 0)
            printf(" ");
        printf("%d", D[i]);
    }
    printf("\n");

    exit(0);
}

int tryCombination(int S[]) {
    int i;

	for (int i = 0; i < N; i++)
		cout << S[i] << ' ';
	

    if (num_calls >= MAX_CALLS) {
        printf("INCORRECT\nToo many calls to tryCombination().\n");
        exit(0);
    }
    ++num_calls;

    for (i = 0; i < N; ++i)
        if (S[inv[i]] != realS[inv[i]]) {
        	cout << i << '\n';
        	return i;
        }
    cout << "-1\n";
    return -1;
}

int init() {
    int i, res;

	res = scanf("%d", &N);

    for (i = 0; i < N; ++i) {
        res = scanf("%d", &realS[i]);
    }
    for (i = 0; i < N; ++i) {
        res = scanf("%d", &realD[i]);
        inv[realD[i]] = i;
    }

    num_calls = 0;
    return N;
}

int main() {
    int N;
	N = init();
	exploreCave(N);
    printf("INCORRECT\nYour solution did not call answer().\n");
	return 0;
}

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

cave.cpp: In function 'int init()':
cave.cpp:131:12: warning: variable 'res' set but not used [-Wunused-but-set-variable]
  131 |     int i, res;
      |            ^~~
/usr/bin/ld: /tmp/ccumcqM7.o: in function `answer':
cave.cpp:(.text+0x0): multiple definition of `answer'; /tmp/cc6r9H26.o:grader.c:(.text+0x0): first defined here
/usr/bin/ld: /tmp/ccumcqM7.o: in function `tryCombination':
cave.cpp:(.text+0x150): multiple definition of `tryCombination'; /tmp/cc6r9H26.o:grader.c:(.text+0x80): first defined here
/usr/bin/ld: /tmp/ccumcqM7.o: in function `init()':
cave.cpp:(.text+0x830): multiple definition of `init()'; /tmp/cc6r9H26.o:grader.c:(.text+0x110): first defined here
/usr/bin/ld: /tmp/ccumcqM7.o: in function `main':
cave.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/cc6r9H26.o:grader.c:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status