답안 #18656

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
18656 2016-02-13T11:35:31 Z suhgyuho_william 말 (IOI15_horses) C++
34 / 100
88 ms 12812 KB
#include "horses.h"

int N;
long long ans,sb3;
long long x[500002],y[500002];

#define MOD 1000000007

long long inv(long long value){
	if(value == 1) return 1;
	long long tmp = (inv(MOD%value)*((-value)/MOD));
	tmp %= MOD;
	if(tmp < 0) tmp += MOD;
	return tmp;
}

int process1(){
	int i,t;
	long long tmp;

    ans = x[1];
    t = tmp = 1;
    for(i=2; i<=N; i++){
		tmp *= x[i];
		if(tmp > y[t] || tmp*y[i] > y[t]){
			t = i;
			ans *= (tmp%MOD); ans %= MOD;
			tmp = 1;
		}
    }
    sb3 = 1;
	for(i=1; i<=N-30; i++){
		sb3 *= x[i];
		sb3 %= MOD;
    }
    ans *= y[t];
    ans %= MOD;

	return (int)ans;
}

void subtask3(){
	int i,t;
	long long tmp;

	ans = x[N-29]*sb3; ans %= MOD;
	t = N-29; tmp = 1;
	for(i=N-28; i<=N; i++){
		tmp *= x[i];
		if(tmp > y[t] || tmp*y[i] > y[t]){
			t = i;
			ans *= (tmp%MOD); ans %= MOD;
			tmp = 1;
		}
	}
	ans *= y[t];
	ans %= MOD;
}

int init(int n, int X[], int Y[]) {
    int i;

    for(i=1; i<=n; i++){
		x[i] = (long long)X[i-1];
		y[i] = (long long)Y[i-1];
    }
    N = n;
    process1();
}

int updateX(int pos, int val) {
	pos++;
	if(N <= 1000){ x[pos] = (long long)val; return process1(); }
	if(N-29 <= pos){
		x[pos] = (long long)val;
		subtask3();
	}else{
		ans *= inv(x[pos]); sb3 *= inv(x[pos]);
		ans %= MOD; sb3 %= MOD;
		x[pos] = (long long)val;
		ans *= x[pos]; sb3 *= x[pos];
		ans %= MOD; sb3 %= MOD;
	}
	return (int)ans;
}

int updateY(int pos, int val) {
	pos++;
	if(N <= 1000){ y[pos] = (long long)val; return process1(); }
	if(N-29 <= pos){
		y[pos] = (long long)val;
		subtask3();
	}else{
		y[pos] = (long long)val;
	}
	return (int)ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 8900 KB Output is correct
2 Correct 0 ms 8900 KB Output is correct
3 Correct 0 ms 8900 KB Output is correct
4 Correct 0 ms 8900 KB Output is correct
5 Correct 0 ms 8900 KB Output is correct
6 Correct 0 ms 8900 KB Output is correct
7 Correct 0 ms 8900 KB Output is correct
8 Correct 0 ms 8900 KB Output is correct
9 Correct 0 ms 8900 KB Output is correct
10 Correct 0 ms 8900 KB Output is correct
11 Correct 0 ms 8900 KB Output is correct
12 Correct 0 ms 8900 KB Output is correct
13 Correct 0 ms 8900 KB Output is correct
14 Correct 0 ms 8900 KB Output is correct
15 Correct 0 ms 8900 KB Output is correct
16 Correct 0 ms 8900 KB Output is correct
17 Correct 0 ms 8900 KB Output is correct
18 Correct 0 ms 8900 KB Output is correct
19 Correct 0 ms 8900 KB Output is correct
20 Correct 0 ms 8900 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 8900 KB Output is correct
2 Correct 0 ms 8900 KB Output is correct
3 Correct 0 ms 8900 KB Output is correct
4 Correct 0 ms 8900 KB Output is correct
5 Correct 0 ms 8900 KB Output is correct
6 Correct 0 ms 8900 KB Output is correct
7 Correct 0 ms 8900 KB Output is correct
8 Correct 0 ms 8900 KB Output is correct
9 Correct 0 ms 8900 KB Output is correct
10 Correct 0 ms 8900 KB Output is correct
11 Correct 0 ms 8900 KB Output is correct
12 Correct 0 ms 8900 KB Output is correct
13 Correct 0 ms 8900 KB Output is correct
14 Correct 0 ms 8900 KB Output is correct
15 Correct 0 ms 8900 KB Output is correct
16 Correct 0 ms 8900 KB Output is correct
17 Correct 0 ms 8900 KB Output is correct
18 Correct 0 ms 8900 KB Output is correct
19 Correct 0 ms 8900 KB Output is correct
20 Correct 0 ms 8900 KB Output is correct
21 Correct 0 ms 8900 KB Output is correct
22 Correct 0 ms 8900 KB Output is correct
23 Correct 11 ms 8900 KB Output is correct
24 Correct 11 ms 8900 KB Output is correct
25 Correct 15 ms 8900 KB Output is correct
26 Correct 14 ms 8900 KB Output is correct
27 Correct 10 ms 8900 KB Output is correct
28 Correct 13 ms 8900 KB Output is correct
29 Correct 6 ms 8900 KB Output is correct
30 Correct 11 ms 8900 KB Output is correct
31 Correct 10 ms 8900 KB Output is correct
32 Correct 9 ms 8900 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 71 ms 12812 KB Output is correct
2 Incorrect 88 ms 12812 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 8900 KB Output is correct
2 Correct 0 ms 8900 KB Output is correct
3 Correct 0 ms 8900 KB Output is correct
4 Correct 0 ms 8900 KB Output is correct
5 Correct 0 ms 8900 KB Output is correct
6 Correct 0 ms 8900 KB Output is correct
7 Correct 0 ms 8900 KB Output is correct
8 Correct 0 ms 8900 KB Output is correct
9 Correct 0 ms 8900 KB Output is correct
10 Correct 0 ms 8900 KB Output is correct
11 Correct 0 ms 8900 KB Output is correct
12 Correct 0 ms 8900 KB Output is correct
13 Correct 0 ms 8900 KB Output is correct
14 Correct 0 ms 8900 KB Output is correct
15 Correct 0 ms 8900 KB Output is correct
16 Correct 0 ms 8900 KB Output is correct
17 Correct 0 ms 8900 KB Output is correct
18 Correct 0 ms 8900 KB Output is correct
19 Correct 0 ms 8900 KB Output is correct
20 Correct 0 ms 8900 KB Output is correct
21 Correct 0 ms 8900 KB Output is correct
22 Correct 0 ms 8900 KB Output is correct
23 Correct 11 ms 8900 KB Output is correct
24 Correct 7 ms 8900 KB Output is correct
25 Correct 15 ms 8900 KB Output is correct
26 Correct 12 ms 8900 KB Output is correct
27 Correct 10 ms 8900 KB Output is correct
28 Correct 13 ms 8900 KB Output is correct
29 Correct 6 ms 8900 KB Output is correct
30 Correct 13 ms 8900 KB Output is correct
31 Correct 10 ms 8900 KB Output is correct
32 Correct 10 ms 8900 KB Output is correct
33 Incorrect 51 ms 12812 KB Output isn't correct
34 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 8900 KB Output is correct
2 Correct 0 ms 8900 KB Output is correct
3 Correct 0 ms 8900 KB Output is correct
4 Correct 0 ms 8900 KB Output is correct
5 Correct 0 ms 8900 KB Output is correct
6 Correct 0 ms 8900 KB Output is correct
7 Correct 0 ms 8900 KB Output is correct
8 Correct 0 ms 8900 KB Output is correct
9 Correct 0 ms 8900 KB Output is correct
10 Correct 0 ms 8900 KB Output is correct
11 Correct 0 ms 8900 KB Output is correct
12 Correct 0 ms 8900 KB Output is correct
13 Correct 0 ms 8900 KB Output is correct
14 Correct 0 ms 8900 KB Output is correct
15 Correct 0 ms 8900 KB Output is correct
16 Correct 0 ms 8900 KB Output is correct
17 Correct 0 ms 8900 KB Output is correct
18 Correct 0 ms 8900 KB Output is correct
19 Correct 0 ms 8900 KB Output is correct
20 Correct 0 ms 8900 KB Output is correct
21 Correct 0 ms 8900 KB Output is correct
22 Correct 0 ms 8900 KB Output is correct
23 Correct 11 ms 8900 KB Output is correct
24 Correct 11 ms 8900 KB Output is correct
25 Correct 15 ms 8900 KB Output is correct
26 Correct 14 ms 8900 KB Output is correct
27 Correct 10 ms 8900 KB Output is correct
28 Correct 10 ms 8900 KB Output is correct
29 Correct 9 ms 8900 KB Output is correct
30 Correct 12 ms 8900 KB Output is correct
31 Correct 10 ms 8900 KB Output is correct
32 Correct 0 ms 8900 KB Output is correct
33 Correct 43 ms 12812 KB Output is correct
34 Incorrect 69 ms 12812 KB Output isn't correct
35 Halted 0 ms 0 KB -