제출 #1335904

#제출 시각아이디문제언어결과실행 시간메모리
1335904enson메기 농장 (IOI22_fish)C++20
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std;

long long max_weights(int N, int M, int[] X, int[] Y, int[] W){
    bool st1 = true;
    for(int i = 0; i < M; i++) st1 &= (X[i]%2==0);
    bool st2 = true;
    for(int i = 0; i < M; i++) st2 &= (X[i]<=1);
    bool st3 = true;
    for(int i = 0; i < M; i++) st3 &= (Y[i]==0);
    if (st1){
        long long ans = 0;
        for(int i = 0; i < M; i++){
            ans += W[i];
        }
        return ans;
    }
    if (st2){
        long long e = 0, o = 0;
        for(int i = 0; i < M; i++){
            if (X[i] == 0) e += W[i];
            else o += W[i];
        }
        return max(e, o);
    }
    if (st3){
        int A[M] = {0};
        A[0] = W[0];
        A[1] = W[1];
        for(int i = 2; i < M; i++){
            A[i] = max(A[i-2] + W[i], A[i-1]);
        }
        return max(A[M-1], A[M-2]);
    }
}

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

fish.cpp:4:43: error: expected ',' or '...' before 'X'
    4 | long long max_weights(int N, int M, int[] X, int[] Y, int[] W){
      |                                           ^
fish.cpp: In function 'long long int max_weights(int, int, int*)':
fish.cpp:6:40: error: 'X' was not declared in this scope
    6 |     for(int i = 0; i < M; i++) st1 &= (X[i]%2==0);
      |                                        ^
fish.cpp:8:40: error: 'X' was not declared in this scope
    8 |     for(int i = 0; i < M; i++) st2 &= (X[i]<=1);
      |                                        ^
fish.cpp:10:40: error: 'Y' was not declared in this scope
   10 |     for(int i = 0; i < M; i++) st3 &= (Y[i]==0);
      |                                        ^
fish.cpp:14:20: error: 'W' was not declared in this scope
   14 |             ans += W[i];
      |                    ^
fish.cpp:21:17: error: 'X' was not declared in this scope
   21 |             if (X[i] == 0) e += W[i];
      |                 ^
fish.cpp:21:33: error: 'W' was not declared in this scope
   21 |             if (X[i] == 0) e += W[i];
      |                                 ^
fish.cpp:22:23: error: 'W' was not declared in this scope
   22 |             else o += W[i];
      |                       ^
fish.cpp:28:16: error: 'W' was not declared in this scope
   28 |         A[0] = W[0];
      |                ^
fish.cpp:35:1: warning: control reaches end of non-void function [-Wreturn-type]
   35 | }
      | ^