답안 #1005000

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1005000 2024-06-22T05:59:09 Z Mr_Husanboy 말 (IOI15_horses) C++17
17 / 100
54 ms 16984 KB
#include "horses.h"
#include<bits/stdc++.h>

using namespace std;
#define ll long long

template<typename T>
int len(T &a){return a.size();}
#define ff first
#define ss second
#define all(a) (a).begin(), (a).end()

int mod = 1e9 + 7;
vector<ll> x, y;
const int inf = 1e9;
int n;

vector<ll> pref;

int init(int N, int X[], int Y[]) {
	n = N;
	x.resize(n), y.resize(n);
	pref.resize(n);
	for(int i = 0; i < n; i ++) x[i] = X[i], y[i] = Y[i];
	pref[0] = x[0];
	for(int i = 1; i < n; i ++) pref[i] = pref[i - 1] * x[i] % mod;
	ll mult = 1;
	ll mx = 0;
	int lim = -1;
	for(int i = n - 1; i >= 0; i --){
		mult *= x[i];
		if(mult >= inf){
			lim = i;
			break;
		}
	}
	mult = 1;
	if(lim >= 0) mx = y[lim];
	for(int i = lim + 1; i < n; i ++){
		mult *= x[i];
		mx = max(mx, mult * y[i]);
	}
	//cout << mx << endl;
	mx %= mod;

	if(lim >= 0) mx = mx * pref[lim] % mod;
	//cout << mx << endl;
	return mx;
}

int updateX(int pos, int val) {
	x[pos] = val;
	ll mult = 1;
	ll mx = 0;
	int lim = -1;
	for(int i = n - 1; i >= 0; i --){
		mult *= x[i];
		if(mult >= inf){
			lim = i;
			break;
		}
	}
	mult = 1;

	if(lim >= 0) mx = y[lim];
	for(int i = lim + 1; i < n; i ++){
		mult *= x[i];
		mx = max(mx, mult * y[i]);
	}

	mx %= mod;
	if(lim >= 0) mx = mx * pref[lim] % mod;
	//cout << mx << endl;
	return mx;
}

int updateY(int pos, int val) {
	y[pos] = val;
	ll mult = 1;
	ll mx = 0;
	int lim = -1;
	for(int i = n - 1; i >= 0; i --){
		mult *= x[i];
		if(mult >= inf){
			lim = i;
			break;
		}
	}
	mult = 1;

	if(lim >= 0) mx = y[lim];
	for(int i = lim + 1; i < n; i ++){
		mult *= x[i];
		mx = max(mx, mult * y[i]);
	}

	mx %= mod;
	if(lim >= 0) mx = pref[lim] * mx % mod;
	//cout << mx << endl;
	return mx;
}

Compilation message

horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:48:9: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   48 |  return mx;
      |         ^~
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:74:9: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   74 |  return mx;
      |         ^~
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:100:9: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
  100 |  return mx;
      |         ^~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 344 KB Output is correct
20 Correct 0 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Incorrect 0 ms 348 KB Output isn't correct
22 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 31 ms 16984 KB Output is correct
2 Incorrect 54 ms 16980 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 600 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Incorrect 0 ms 348 KB Output isn't correct
22 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 344 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 344 KB Output is correct
21 Incorrect 0 ms 348 KB Output isn't correct
22 Halted 0 ms 0 KB -