답안 #754906

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
754906 2023-06-08T21:47:43 Z APROHACK 말 (IOI15_horses) C++14
54 / 100
1500 ms 29760 KB
#include <bits/stdc++.h>
#include "horses.h"
#define ll long long
#define pb push_back
const ll mod = 1e9+7;
using namespace std;
int n;
ll maxV = 0;
ll acum[500005];
vector<ll>x, y;

ll fastExp(ll base, int pot){
	if(pot == 0)return 1;
	ll temp = fastExp(base, pot/2);
	temp = temp * temp % mod;
	if(pot % 2 == 1)temp = (temp * base) % mod;
	return temp;
}

ll query(int pos){
	ll ans = 1;
	for(; pos>= 1 ; pos -= (pos&-pos)){
		ans *= acum[pos];
		ans %= mod;
	}
	return ans;
}
void multiplicar(int pos , int value){
	for(; pos<= n ; pos += pos&(-pos)){
		acum[pos] *= value;
		acum[pos] %= mod;
	}
}

void updateRet(){
	ll ans = query(n) * y[n-1] % mod;
	ll current = x[n-1]* y[n-1];
	for(int i = n-2 ; i >= 0 ; i --){
		if(current > 1e9){
			maxV = ans;
			return ;
		}
		if(current < y[i]){
			ans = query(i+1) * y[i] % mod;
			current = x[i]*y[i];
		}else{
			current = current * x[i];
		}
	}
	maxV = ans;
}
int init(int N, int X[], int Y[]) {
	n = N;
	for(int i = 0 ; i <= n ; i ++)acum[i] = 1;
	for(int i = 0 ; i < N ; i++){
		x.pb(X[i]);
		y.pb(Y[i]);
		multiplicar(i+1, X[i]);
	}
	updateRet();
	return maxV%mod;
}

int updateX(int pos, int val) {	
	multiplicar(pos + 1, fastExp(x[pos], mod-2));
	x[pos] = val;
	multiplicar(pos + 1, x[pos]);
	updateRet();
	return maxV%mod;
}

int updateY(int pos, int val) {
	y[pos] = val;
	updateRet();
	return maxV%mod;
}

Compilation message

horses.cpp: In function 'void updateRet()':
horses.cpp:39:6: warning: conversion from 'long long int' to 'double' may change value [-Wconversion]
   39 |   if(current > 1e9){
      |      ^~~~~~~
horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:61:13: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   61 |  return maxV%mod;
      |         ~~~~^~~~
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:65:30: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   65 |  multiplicar(pos + 1, fastExp(x[pos], mod-2));
      |                       ~~~~~~~^~~~~~~~~~~~~~~
horses.cpp:67:29: 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]
   67 |  multiplicar(pos + 1, x[pos]);
      |                             ^
horses.cpp:69:13: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   69 |  return maxV%mod;
      |         ~~~~^~~~
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:75:13: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   75 |  return maxV%mod;
      |         ~~~~^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 0 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 2 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 2 ms 340 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 2 ms 340 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 53 ms 17060 KB Output is correct
2 Correct 107 ms 29696 KB Output is correct
3 Correct 80 ms 20836 KB Output is correct
4 Correct 105 ms 24744 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 2 ms 340 KB Output is correct
30 Correct 2 ms 340 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 63 ms 16196 KB Output is correct
34 Correct 45 ms 20164 KB Output is correct
35 Correct 74 ms 27108 KB Output is correct
36 Correct 69 ms 27032 KB Output is correct
37 Correct 260 ms 18556 KB Output is correct
38 Correct 43 ms 19240 KB Output is correct
39 Execution timed out 1570 ms 18236 KB Time limit exceeded
40 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 2 ms 340 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 2 ms 340 KB Output is correct
32 Correct 2 ms 340 KB Output is correct
33 Correct 56 ms 18720 KB Output is correct
34 Correct 120 ms 29760 KB Output is correct
35 Correct 72 ms 20900 KB Output is correct
36 Correct 98 ms 24808 KB Output is correct
37 Correct 63 ms 20200 KB Output is correct
38 Correct 49 ms 20116 KB Output is correct
39 Correct 69 ms 27188 KB Output is correct
40 Correct 66 ms 27044 KB Output is correct
41 Correct 249 ms 18512 KB Output is correct
42 Correct 40 ms 19216 KB Output is correct
43 Execution timed out 1577 ms 18232 KB Time limit exceeded
44 Halted 0 ms 0 KB -