답안 #642203

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
642203 2022-09-18T22:09:05 Z tigar 메기 농장 (IOI22_fish) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

int64_t max_weights(int N, int M, int []X, int []Y, int []W)
{
    bool subtask1=true, subtask2=true, subtask3=true;
    for(int i=0; i<M; i++)
    {
        if(X[i]%2!=0)subtask1=false;
        if(X[i]>1)subtask2=false;
        if(Y[i]!=0)subtask3=false;
    }
    if(subtask1)
    {
        ll rez=0;
        for(int i=0; i<M; i++)rez+=W[i];
        return rez;
    }
    if(subtask2)
    {
        ll s1=0, s0=0, m[N][2];
        for(int i=0; i<M; i++)
        {
            if(X[i]==0)s0+=W[i];
            else s1+=W[i];
            m[Y[i]][X[i]]=W[i];
        }
        for(int i=0; i<N; i++)
        {
            m[i][0]=m[max(i-1, 0)][0]+m[i][0];
            m[i][1]=m[max(i-1, 0)][1]+m[i][1];
        }
        if(N==2)return max(m[N-1][0], m[N-1][1]);
        ll rez=0;
        for(int i=0; i<N; i++)
        {
            rez=max(rez, m[i][0]+m[N-1][1]-m[i][0]);
        }
        return rez;
    }
}

Compilation message

fish.cpp:6:41: error: expected ',' or '...' before 'X'
    6 | int64_t max_weights(int N, int M, int []X, int []Y, int []W)
      |                                         ^
fish.cpp: In function 'int64_t max_weights(int, int, int*)':
fish.cpp:11:12: error: 'X' was not declared in this scope
   11 |         if(X[i]%2!=0)subtask1=false;
      |            ^
fish.cpp:12:12: error: 'X' was not declared in this scope
   12 |         if(X[i]>1)subtask2=false;
      |            ^
fish.cpp:13:12: error: 'Y' was not declared in this scope
   13 |         if(Y[i]!=0)subtask3=false;
      |            ^
fish.cpp:18:36: error: 'W' was not declared in this scope
   18 |         for(int i=0; i<M; i++)rez+=W[i];
      |                                    ^
fish.cpp:26:16: error: 'X' was not declared in this scope
   26 |             if(X[i]==0)s0+=W[i];
      |                ^
fish.cpp:26:28: error: 'W' was not declared in this scope
   26 |             if(X[i]==0)s0+=W[i];
      |                            ^
fish.cpp:27:22: error: 'W' was not declared in this scope
   27 |             else s1+=W[i];
      |                      ^
fish.cpp:28:15: error: 'Y' was not declared in this scope
   28 |             m[Y[i]][X[i]]=W[i];
      |               ^
fish.cpp:28:21: error: 'X' was not declared in this scope
   28 |             m[Y[i]][X[i]]=W[i];
      |                     ^
fish.cpp:28:27: error: 'W' was not declared in this scope
   28 |             m[Y[i]][X[i]]=W[i];
      |                           ^
fish.cpp:43:1: warning: control reaches end of non-void function [-Wreturn-type]
   43 | }
      | ^