답안 #703408

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
703408 2023-02-27T09:21:00 Z Stavab 말 (IOI15_horses) C++14
0 / 100
1500 ms 19816 KB
#include "horses.h"
#include <vector>

#define ll long long 
#define MOD 1000000007

using namespace std;

struct num
{
    ll a; ll b;

    num(ll x, ll y): a(x), b(y) {};

    void operator*=(int x)
    {
        a *= (ll)x;
        b *= (ll)x;
        if(b >= MOD)
        {
            b %= MOD;
            ++a;
        }
    }
    bool operator<(const num &n) const
    {
        if(a != n.a) return a < n.a;
        else return b < n.b;
    }
};

vector<num> mult;
vector<ll> x, y;

int ans()
{
    num maxVal(0, 0);
    for(int i = 0; i < mult.size(); i++)
    {
        num tmp = mult[i];
        tmp *= y[i];
        maxVal = max(maxVal, tmp);
    }

    return maxVal.b;
}

int init(int N, int X[], int Y[])
{
    mult.assign(N, num(0, 0));
    mult[0].b = 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++)
    {
        num tmp = mult[i - 1];
        tmp *= x[i];
        mult[i] = tmp;

        y[i] = (long long)Y[i];
        x[i] = (long long)X[i];
    }

    return ans();
}

int updateX(int pos, int val)
{
    x[pos] = (long long)val;

    if(!pos)
    {
    	mult[0].b = x[0];
        pos++;
    }
    for(int i = pos; i < mult.size(); i++)
    {
        num tmp = mult[i - 1];
        tmp *= x[i];
        mult[i] = tmp;
    }
    return ans();
}

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

Compilation message

horses.cpp: In function 'int ans()':
horses.cpp:38:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<num>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |     for(int i = 0; i < mult.size(); i++)
      |                    ~~^~~~~~~~~~~~~
horses.cpp:41:19: warning: conversion from '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'} to 'int' may change value [-Wconversion]
   41 |         tmp *= y[i];
      |                   ^
horses.cpp:45:19: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   45 |     return maxVal.b;
      |            ~~~~~~~^
horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:61:19: warning: conversion from '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'} to 'int' may change value [-Wconversion]
   61 |         tmp *= x[i];
      |                   ^
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:80:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<num>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   80 |     for(int i = pos; i < mult.size(); i++)
      |                      ~~^~~~~~~~~~~~~
horses.cpp:83:19: warning: conversion from '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'} to 'int' may change value [-Wconversion]
   83 |         tmp *= x[i];
      |                   ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1570 ms 19816 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -