답안 #774337

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
774337 2023-07-05T15:26:24 Z MarwenElarbi 코알라 (APIO17_koala) C++17
컴파일 오류
0 ms 0 KB
#include "koala.h"
#include <stdio.h>
#include <stdlib.h>
//#include <bits/stdc++.h>
//using namespace std;
static int N, W;
static int P[105];

static int maxQueries = 3200;
static int numQueries;

static void runGame(int F);
static void grader();

int main() {
    grader();
    return 0;
}

/*void playRound(int *B, int *R) {
    int i, j;

    int S = 0;
    for (i=0;i<N;++i) {
        if ( !(B[i] >= 0 && B[i] <= W) ) {
            printf("Invalid query.\n");
            exit(0);
        }
        S += B[i];
    }
    if (S > W) {
        printf("Invalid query.\n");
        exit(0);
    }

    numQueries++;
    if (numQueries > maxQueries) {
        printf("Too many queries.\n");
        exit(0);
    }

    int cache[2][205];
    int num[2][205];
    char taken[105][205];

    for (i=0;i<205;++i) {
        cache[1][i] = 0;
        num[1][i] = 0;
    }

    for (i=0;i<N;++i) {
        int v = B[i]+1;
        int ii = i&1;
        int o = ii^1;
        for (j=0;j<=W;++j) {
            cache[ii][j] = cache[o][j];
            num[ii][j] = num[o][j];
            taken[i][j] = 0;
        }
        for (j=W;j>=v;--j) {
            int h = cache[o][j-v] + P[i];
            int hn = num[o][j-v] + 1;
            if (h > cache[ii][j] || (h == cache[ii][j] && hn > num[ii][j])) {
                cache[ii][j] = h;
                num[ii][j] = hn;
                taken[i][j] = 1;
            } else {
                taken[i][j] = 0;
            }
        }
    }

    int cur = W;
    for (i=N-1;i>=0;--i) {
        R[i] = taken[i][cur] ? (B[i] + 1) : 0;
        cur -= R[i];
    }
}*/
int minValue(int N,int W){
    vector<int> tab(N,0);
    tab[0]=1;
    vector<int> res(N);
    playRound(&tab, &res);
    for (int i = 0; i < N; ++i)
    {
        if (res[i]==0) return i+1;
    }
    return 1;
}
int maxValue(int N,int W);
int greaterValue(int N,int W);
vector<int> allValues(int N,int W,int P);
/*static void runGame(int F) {
    int i;

    scanf("%d %d",&N,&W);
    for (i=0;i<N;++i) {
        scanf("%d",&P[i]);
    }

    numQueries = 0;
    if (F == 1) {
        printf("%d\n", minValue(N, W));
    } else if (F == 2) {
        printf("%d\n", maxValue(N, W));
    } else if (F == 3) {
        printf("%d\n", greaterValue(N, W));
    } else if (F == 4) {
        int userP[105];
        allValues(N, W, userP);
        for (i=0;i<N;i++) {
            printf("%d ",userP[i]);
        }
        printf("\n");
    }
    printf("Made %d calls to playRound.\n", numQueries);
}

static void grader() {
    int i;

    int F, G;
    scanf("%d %d",&F,&G);

    for (i=0;i<G;i++) {
        runGame(F);
    }
}*/

Compilation message

koala.cpp: In function 'int minValue(int, int)':
koala.cpp:80:5: error: 'vector' was not declared in this scope
   80 |     vector<int> tab(N,0);
      |     ^~~~~~
koala.cpp:80:12: error: expected primary-expression before 'int'
   80 |     vector<int> tab(N,0);
      |            ^~~
koala.cpp:81:5: error: 'tab' was not declared in this scope
   81 |     tab[0]=1;
      |     ^~~
koala.cpp:82:12: error: expected primary-expression before 'int'
   82 |     vector<int> res(N);
      |            ^~~
koala.cpp:83:22: error: 'res' was not declared in this scope
   83 |     playRound(&tab, &res);
      |                      ^~~
koala.cpp: At global scope:
koala.cpp:92:1: error: 'vector' does not name a type
   92 | vector<int> allValues(int N,int W,int P);
      | ^~~~~~
koala.cpp:12:13: warning: 'void runGame(int)' declared 'static' but never defined [-Wunused-function]
   12 | static void runGame(int F);
      |             ^~~~~~~
koala.cpp:13:13: warning: 'void grader()' declared 'static' but never defined [-Wunused-function]
   13 | static void grader();
      |             ^~~~~~
koala.cpp:13:13: warning: 'void grader()' used but never defined
koala.cpp:10:12: warning: 'numQueries' defined but not used [-Wunused-variable]
   10 | static int numQueries;
      |            ^~~~~~~~~~
koala.cpp:9:12: warning: 'maxQueries' defined but not used [-Wunused-variable]
    9 | static int maxQueries = 3200;
      |            ^~~~~~~~~~
koala.cpp:7:12: warning: 'P' defined but not used [-Wunused-variable]
    7 | static int P[105];
      |            ^
koala.cpp:6:15: warning: 'W' defined but not used [-Wunused-variable]
    6 | static int N, W;
      |               ^
koala.cpp:6:12: warning: 'N' defined but not used [-Wunused-variable]
    6 | static int N, W;
      |            ^