답안 #631940

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
631940 2022-08-19T07:53:51 Z Stavab 말 (IOI15_horses) C++14
컴파일 오류
0 ms 0 KB
#include "horses.h"

#include <vector>

using namespace std;

vector<long long> mult, y, x;

int ans()
{
    long long maxVal = 0;
    for(int i = 0; i < mult.size(); i++)
    {
        maxVal = max(maxVal, mult[i]*y[i] % 1000000007);
    }
    
    return (int)maxVal;
}

int init(nt N, int X[], int Y[])
{
    mult.assign(N, 0);
    mult[0] = X[0];
    x.assign(N, 0);
    x[0] = X[0];
    y.assign(N, 0);
    y[0] = Y[0];
    
    for(int i = 1; i < N; i++)
    {
        mult[i] = (mult[i - 1] * X[i]) % 1000000007;
        y[i] = Y[i];
        x[i] = X[i];
    }
    
    return ans();
}

int updateX(int pos, int val)
{
    x[pos] = val;
    for(int i = pos; i < mult.size(); i++)
        mult[i] = mult[i - 1] * x[i];
    return ans();
}

int updateY(int pos, int val)
{
    y[pos] = val;
    return ans();
}

Compilation message

horses.cpp: In function 'int ans()':
horses.cpp:12:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   12 |     for(int i = 0; i < mult.size(); i++)
      |                    ~~^~~~~~~~~~~~~
horses.cpp: At global scope:
horses.cpp:20:10: error: 'int init' redeclared as different kind of entity
   20 | int init(nt N, int X[], int Y[])
      |          ^~
In file included from horses.cpp:1:
horses.h:4:5: note: previous declaration 'int init(int, int*, int*)'
    4 | int init(int N, int X[], int Y[]);
      |     ^~~~
horses.cpp:20:10: error: 'nt' was not declared in this scope; did you mean 'int'?
   20 | int init(nt N, int X[], int Y[])
      |          ^~
      |          int
horses.cpp:20:16: error: expected primary-expression before 'int'
   20 | int init(nt N, int X[], int Y[])
      |                ^~~
horses.cpp:20:25: error: expected primary-expression before 'int'
   20 | int init(nt N, int X[], int Y[])
      |                         ^~~
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:42:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |     for(int i = pos; i < mult.size(); i++)
      |                      ~~^~~~~~~~~~~~~