제출 #1039810

#제출 시각아이디문제언어결과실행 시간메모리
1039810c2zi6말 (IOI15_horses)C++14
34 / 100
1534 ms15960 KiB
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define replr(i, a, b) for (int i = int(a); i <= int(b); ++i)
#define reprl(i, a, b) for (int i = int(a); i >= int(b); --i)
#define rep(i, n) for (int i = 0; i < int(n); ++i)
#define mkp(a, b) make_pair(a, b)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VPI;
typedef vector<VI> VVI;
typedef vector<VVI> VVVI;
typedef vector<VPI> VVPI;
typedef pair<ll, ll> PLL;
typedef vector<ll> VL;
typedef vector<PLL> VPL;
typedef vector<VL> VVL;
typedef vector<VVL> VVVL;
typedef vector<VPL> VVPL;
template<class T> T setmax(T& a, T b) {if (a < b) return a = b; return a;}
template<class T> T setmin(T& a, T b) {if (a < b) return a; return a = b;}
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<typename T>
using indset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#include "horses.h"

const ll MOD = 1e9 + 7;

int n;
VL a, b;

ll recalc() {
    ll leave = n;
    ll prod = 1;
    reprl(i, n-1, 0) {
        if (b[i] > prod) {
            prod = a[i] * b[i];
            leave = i;
        } else {
            prod = a[i] * prod;
        }
        if (prod > 1e9) prod = 1e9;
    }
    ll ans = 1;
    rep(i, n) {
        ans *= a[i];
        ans %= MOD;
        if (i == leave) {
            ans *= b[i];
            ans %= MOD;
            break;
        }
    }
	return ans;
}

int init(int N, int X[], int Y[]) {
    n = N;
    a = b = VL(n);
    rep(i, n) {
        a[i] = X[i];
        b[i] = Y[i];
    }
    return recalc();
}

int updateX(int pos, int val) {	
    a[pos] = val;
	return recalc();
}

int updateY(int pos, int val) {
    b[pos] = val;
	return recalc();
}


컴파일 시 표준 에러 (stderr) 메시지

horses.cpp: In function 'll recalc()':
horses.cpp:49:13: warning: conversion from 'll' {aka 'long long int'} to 'double' may change value [-Wconversion]
   49 |         if (prod > 1e9) prod = 1e9;
      |             ^~~~
horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:71:18: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   71 |     return recalc();
      |            ~~~~~~^~
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:76:15: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   76 |  return recalc();
      |         ~~~~~~^~
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:81:15: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   81 |  return recalc();
      |         ~~~~~~^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...