제출 #834200

#제출 시각아이디문제언어결과실행 시간메모리
834200Ellinor말 (IOI15_horses)C++14
17 / 100
1558 ms12064 KiB
//#include<bits/stdc++.h>
#include <iostream>
#include <vector>
#include <queue>
#include <string>
#include <cmath>
#include <cstdlib>
#include <set>
#include <iomanip>
#include <limits>
#include <map>
#include <assert.h>
#include <algorithm>
#include <list>
#include <iterator>
#include <fstream>
#include <random>
#include <unordered_map>
#include <array>
using namespace std;

#define rep(i,a,b) for (int i = (a); i < b; i++)
#define pb push_back
#define all(x) x.begin(), x.end()
typedef long long ll;
typedef pair<int, int> pii;

ll MOD = 1e9 + 7; // !?

// fast

#include "horses.h" // !

int n;
vector<ll> x, y;

int init(int N, int X[], int Y[]) 
{
    n = N;
    x.assign(N, 0);
    y.assign(N, 0);
    rep(i,0,N) {
        x[i] = X[i];
        y[i] = Y[i];
    }

    //

    ll ch = 1, sind;
    for (int i = n; i >= 0; i--)
    {
        ch *= x[i];
        if (ch > 1e9) {
            sind = i + 1;
            break;
        }
        if (i = 0) sind = 0;
    }

    ll ans = 0;
    ll horses = 1, tmp;
    rep(i,sind,n) { // start on sind -1"
        horses *= x[i];
        tmp = horses * y[i];
        ans = max(ans, tmp);
    }

	return ans % MOD;
}

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

    ll ch = 1, sind;
    for (int i = n; i >= 0; i--)
    {
        ch *= x[i];
        if (ch > 1e9) {
            sind = i + 1;
            break;
        }
        if (i = 0) sind = 0;
    }

    ll ans = 0;
    ll horses = 1, tmp;
    rep(i,sind,n) { // start on sind -1"
        horses *= x[i];
        tmp = horses * y[i];
        ans = max(ans, tmp);
    }

	return ans % MOD;
}

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

    ll ch = 1, sind;
    for (int i = n; i >= 0; i--)
    {
        ch *= x[i];
        if (ch > 1e9) {
            sind = i + 1;
            break;
        }
        if (i = 0) sind = 0;
    }

    ll ans = 0;
    ll horses = 1, tmp;
    rep(i,sind,n) { // start on sind -1"
        horses *= x[i];
        tmp = horses * y[i];
        ans = max(ans, tmp);
    }

	return ans % MOD;
}

// 17p, M = 0

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

horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:53:13: warning: conversion from 'll' {aka 'long long int'} to 'double' may change value [-Wconversion]
   53 |         if (ch > 1e9) {
      |             ^~
horses.cpp:57:15: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   57 |         if (i = 0) sind = 0;
      |             ~~^~~
horses.cpp:62:11: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   22 | #define rep(i,a,b) for (int i = (a); i < b; i++)
      |                                 ~~~
......
   62 |     rep(i,sind,n) { // start on sind -1"
horses.cpp:22:34: note: in definition of macro 'rep'
   22 | #define rep(i,a,b) for (int i = (a); i < b; i++)
      |                                  ^
horses.cpp:68:13: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   68 |  return ans % MOD;
      |         ~~~~^~~~~
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:79:13: warning: conversion from 'll' {aka 'long long int'} to 'double' may change value [-Wconversion]
   79 |         if (ch > 1e9) {
      |             ^~
horses.cpp:83:15: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   83 |         if (i = 0) sind = 0;
      |             ~~^~~
horses.cpp:88:11: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   22 | #define rep(i,a,b) for (int i = (a); i < b; i++)
      |                                 ~~~
......
   88 |     rep(i,sind,n) { // start on sind -1"
horses.cpp:22:34: note: in definition of macro 'rep'
   22 | #define rep(i,a,b) for (int i = (a); i < b; i++)
      |                                  ^
horses.cpp:94:13: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   94 |  return ans % MOD;
      |         ~~~~^~~~~
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:105:13: warning: conversion from 'll' {aka 'long long int'} to 'double' may change value [-Wconversion]
  105 |         if (ch > 1e9) {
      |             ^~
horses.cpp:109:15: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
  109 |         if (i = 0) sind = 0;
      |             ~~^~~
horses.cpp:114:11: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   22 | #define rep(i,a,b) for (int i = (a); i < b; i++)
      |                                 ~~~
......
  114 |     rep(i,sind,n) { // start on sind -1"
horses.cpp:22:34: note: in definition of macro 'rep'
   22 | #define rep(i,a,b) for (int i = (a); i < b; i++)
      |                                  ^
horses.cpp:120:13: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
  120 |  return ans % MOD;
      |         ~~~~^~~~~
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:88:9: warning: 'sind' may be used uninitialized in this function [-Wmaybe-uninitialized]
   88 |     rep(i,sind,n) { // start on sind -1"
      |         ^
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:114:9: warning: 'sind' may be used uninitialized in this function [-Wmaybe-uninitialized]
  114 |     rep(i,sind,n) { // start on sind -1"
      |         ^
horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:62:9: warning: 'sind' may be used uninitialized in this function [-Wmaybe-uninitialized]
   62 |     rep(i,sind,n) { // start on sind -1"
      |         ^
#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...