답안 #709897

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

#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:7:1: error: 'vector' does not name a type
    7 | vector<int> xg;
      | ^~~~~~
horses.cpp:8:1: error: 'vector' does not name a type
    8 | vector<int> yg;
      | ^~~~~~
horses.cpp:10:17: error: 'vector' has not been declared
   10 | int init(int n, vector<int> x, vector<int> y)
      |                 ^~~~~~
horses.cpp:10:23: error: expected ',' or '...' before '<' token
   10 | int init(int n, vector<int> x, vector<int> y)
      |                       ^
horses.cpp: In function 'int init(int, int)':
horses.cpp:13:5: error: 'xg' was not declared in this scope; did you mean 'ng'?
   13 |     xg = x;
      |     ^~
      |     ng
horses.cpp:13:10: error: 'x' was not declared in this scope
   13 |     xg = x;
      |          ^
horses.cpp:14:5: error: 'yg' was not declared in this scope; did you mean 'ng'?
   14 |     yg = y;
      |     ^~
      |     ng
horses.cpp:14:10: error: 'y' was not declared in this scope
   14 |     yg = y;
      |          ^
horses.cpp:25:11: error: 'max' was not declared in this scope; did you mean 'std::max'?
   25 |     now = max(now, 0);
      |           ^~~
      |           std::max
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from horses.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: 'std::max' declared here
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
horses.cpp:43:12: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   43 |     return mx;
      |            ^~
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:48:5: error: 'xg' was not declared in this scope; did you mean 'ng'?
   48 |     xg[pos] = val;
      |     ^~
      |     ng
horses.cpp:59:11: error: 'max' was not declared in this scope; did you mean 'std::max'?
   59 |     now = max(now, 0);
      |           ^~~
      |           std::max
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from horses.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: 'std::max' declared here
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
horses.cpp:65:20: error: 'yg' was not declared in this scope; did you mean 'ng'?
   65 |         if(mx < pr*yg[i])
      |                    ^~
      |                    ng
horses.cpp:77:12: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   77 |     return mx;
      |            ^~
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:82:5: error: 'yg' was not declared in this scope; did you mean 'ng'?
   82 |     yg[pos] = val;
      |     ^~
      |     ng
horses.cpp:87:17: error: 'xg' was not declared in this scope; did you mean 'ng'?
   87 |         produs*=xg[now];
      |                 ^~
      |                 ng
horses.cpp:93:11: error: 'max' was not declared in this scope; did you mean 'std::max'?
   93 |     now = max(now, 0);
      |           ^~~
      |           std::max
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from horses.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: 'std::max' declared here
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
horses.cpp:98:13: error: 'xg' was not declared in this scope; did you mean 'ng'?
   98 |         pr*=xg[i];
      |             ^~
      |             ng
horses.cpp:108:13: error: 'xg' was not declared in this scope; did you mean 'ng'?
  108 |         mx*=xg[i];
      |             ^~
      |             ng
horses.cpp:111:12: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
  111 |     return mx;
      |            ^~