답안 #709898

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
709898 2023-03-14T19:00:31 Z ssense 말 (IOI15_horses) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#include "horses.h"

using namespace std;

#define MOD 1000000009

int ng;
vector<int> xg;
vector<int> yg;

int init(int n, vector<int> x, vector<int> y)
{
    ng = n;
    xg = x;
    yg = y;
    int produs = 1;
    int now = ng-1;
    for(; now >= 0; now--)
    {
        produs*=xg[now];
        if(produs >= 1e9)
        {
            break;
        }
    }
    now = max(now, 0);
    long long mx = 0, idx = 0;
    int pr = 1;
    for(int i = now; i < ng; i++)
    {
        pr*=xg[i];
        if(mx < pr*yg[i])
        {
            mx = pr*yg[i];
            idx = i;
        }
    }
    mx%=MOD;
    for(int i = 0; i < idx-1; i++)
    {
        mx*=xg[i];
        mx%=MOD;
    }
    return mx;
}

int updateX(int pos, int val)
{
    xg[pos] = val;
    int produs = 1;
    int now = ng-1;
    for(; now >= 0; now--)
    {
        produs*=xg[now];
        if(produs >= 1e9)
        {
            break;
        }
    }
    now = max(now, 0);
    long long mx = 0, idx = 0;
    int pr = 1;
    for(int i = now; i < ng; i++)
    {
        pr*=xg[i];
        if(mx < pr*yg[i])
        {
            mx = pr*yg[i];
            idx = i;
        }
    }
    mx%=MOD;
    for(int i = 0; i < idx-1; i++)
    {
        mx*=xg[i];
        mx%=MOD;
    }
    return mx;
}

int updateY(int pos, int val)
{
    yg[pos] = val;
    int produs = 1;
    int now = ng-1;
    for(; now >= 0; now--)
    {
        produs*=xg[now];
        if(produs >= 1e9)
        {
            break;
        }
    }
    now = max(now, 0);
    long long mx = 0, idx = 0;
    int pr = 1;
    for(int i = now; i < ng; i++)
    {
        pr*=xg[i];
        if(mx < pr*yg[i])
        {
            mx = pr*yg[i];
            idx = i;
        }
    }
    mx%=MOD;
    for(int i = 0; i < idx-1; i++)
    {
        mx*=xg[i];
        mx%=MOD;
    }
    return mx;
}

Compilation message

horses.cpp: In function 'int init(int, std::vector<int>, std::vector<int>)':
horses.cpp:45:12: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   45 |     return mx;
      |            ^~
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:79:12: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   79 |     return mx;
      |            ^~
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:113:12: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
  113 |     return mx;
      |            ^~
/usr/bin/ld: /tmp/cchVG67Q.o: in function `main':
grader.c:(.text.startup+0xaa): undefined reference to `init(int, int*, int*)'
collect2: error: ld returned 1 exit status