답안 #984201

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
984201 2024-05-16T11:26:57 Z SmuggingSpun 말 (IOI15_horses) C++14
17 / 100
623 ms 21844 KB
#include "horses.h"
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;
const int lim = 5e5 + 5;
int n, st[lim << 2], x_st[lim << 2], y[lim], f[lim];
int get_x_prod(int id, int l, int r, int u, int v){
	if(l > v || r < u){
		return 1;
	}
	if(u <= l && v >= r){
		return x_st[id];
	}
	int m = (l + r) >> 1, left = get_x_prod(id << 1, l, m, u, v);
	if(left == mod){
		return mod;
	}
	return min(ll(mod), 1LL * left * get_x_prod(id << 1 | 1, m + 1, r, u, v));
}
int merge(int l, int r){
	if(l == 0){
		return r;
	}
	if(r == 0){
		return l;
	}
	return 1LL * get_x_prod(1, 1, n, l + 1, r) * y[r] < ll(y[l]) ? l : r;
}
void update_X(int id, int l, int r, int p, int x){
	if(l == r){
		st[id] = l;
		x_st[id] = x;
		return;
	}
	int m = (l + r) >> 1;
	if(m < p){
		update_X(id << 1 | 1, m + 1, r, p, x);
	}
	else{
		update_X(id << 1, l, m, p, x);
	}
	st[id] = merge(st[id << 1], st[id << 1 | 1]);
	x_st[id] = min(ll(mod), 1LL * x_st[id << 1] * x_st[id << 1 | 1]);
}
void update_Y(int p, int Y){
	y[p] = Y;
	int id = 1, l = 1, r = n;
	while(l < r){
		int m = (l + r) >> 1;
		id <<= 1;
		if(m < p){
			l = m + 1;
			id |= 1;
		}
		else{
			r = m;
		}
	}
	while((id >>= 1) > 0){
		st[id] = merge(st[id << 1], st[id << 1 | 1]);
	}
}
int init(int N, int X[], int Y[]){
	n = N;
	for(int i = f[0] = 1; i <= n; i++){
		f[i] = 1LL * f[i - 1] * X[i - 1] % mod;
		y[i] = Y[i - 1];
	}
	fill(x_st, x_st + (lim << 2), 1);
	for(int i = 1; i <= n; i++){
		update_X(1, 1, n, i, X[i - 1]);
	}
	return 1LL * f[st[1]] * y[st[1]] % mod;
}
int updateX(int pos, int val){	
	update_X(1, 1, n, pos + 1, val);
	return 1LL * f[st[1]] * y[st[1]] % mod;
}
int updateY(int pos, int val){
	update_Y(pos + 1, val);
	return 1LL * f[st[1]] * y[st[1]] % mod;
}

Compilation message

horses.cpp: In function 'int get_x_prod(int, int, int, int, int)':
horses.cpp:19:12: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   19 |  return min(ll(mod), 1LL * left * get_x_prod(id << 1 | 1, m + 1, r, u, v));
      |         ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
horses.cpp: In function 'void update_X(int, int, int, int, int)':
horses.cpp:44:16: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   44 |  x_st[id] = min(ll(mod), 1LL * x_st[id << 1] * x_st[id << 1 | 1]);
      |             ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:67:36: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   67 |   f[i] = 1LL * f[i - 1] * X[i - 1] % mod;
      |          ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
horses.cpp:74:35: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   74 |  return 1LL * f[st[1]] * y[st[1]] % mod;
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:78:35: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   78 |  return 1LL * f[st[1]] * y[st[1]] % mod;
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:82:35: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   82 |  return 1LL * f[st[1]] * y[st[1]] % mod;
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 12636 KB Output is correct
2 Correct 2 ms 12636 KB Output is correct
3 Correct 2 ms 12748 KB Output is correct
4 Correct 2 ms 12636 KB Output is correct
5 Correct 2 ms 12636 KB Output is correct
6 Correct 3 ms 12636 KB Output is correct
7 Correct 3 ms 12732 KB Output is correct
8 Correct 2 ms 12632 KB Output is correct
9 Correct 2 ms 12636 KB Output is correct
10 Correct 2 ms 12632 KB Output is correct
11 Correct 2 ms 12636 KB Output is correct
12 Correct 2 ms 12636 KB Output is correct
13 Correct 2 ms 12636 KB Output is correct
14 Correct 3 ms 12632 KB Output is correct
15 Correct 2 ms 12636 KB Output is correct
16 Correct 3 ms 12636 KB Output is correct
17 Correct 2 ms 12632 KB Output is correct
18 Correct 2 ms 12636 KB Output is correct
19 Correct 2 ms 12636 KB Output is correct
20 Correct 2 ms 12636 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 12636 KB Output is correct
2 Correct 2 ms 12636 KB Output is correct
3 Correct 2 ms 12632 KB Output is correct
4 Correct 3 ms 12636 KB Output is correct
5 Correct 2 ms 12632 KB Output is correct
6 Correct 2 ms 12636 KB Output is correct
7 Correct 3 ms 12636 KB Output is correct
8 Correct 3 ms 12636 KB Output is correct
9 Correct 2 ms 12636 KB Output is correct
10 Correct 2 ms 12632 KB Output is correct
11 Correct 3 ms 12636 KB Output is correct
12 Correct 2 ms 12636 KB Output is correct
13 Correct 2 ms 12740 KB Output is correct
14 Correct 2 ms 12636 KB Output is correct
15 Correct 2 ms 12636 KB Output is correct
16 Correct 2 ms 12724 KB Output is correct
17 Correct 3 ms 12636 KB Output is correct
18 Correct 2 ms 12636 KB Output is correct
19 Correct 2 ms 12636 KB Output is correct
20 Correct 2 ms 12636 KB Output is correct
21 Incorrect 2 ms 12636 KB Output isn't correct
22 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 623 ms 21844 KB Output is correct
2 Incorrect 603 ms 21700 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 12636 KB Output is correct
2 Correct 2 ms 12632 KB Output is correct
3 Correct 2 ms 12636 KB Output is correct
4 Correct 2 ms 12636 KB Output is correct
5 Correct 3 ms 12636 KB Output is correct
6 Correct 2 ms 12636 KB Output is correct
7 Correct 2 ms 12636 KB Output is correct
8 Correct 2 ms 12636 KB Output is correct
9 Correct 2 ms 12636 KB Output is correct
10 Correct 3 ms 12636 KB Output is correct
11 Correct 2 ms 12632 KB Output is correct
12 Correct 2 ms 12636 KB Output is correct
13 Correct 2 ms 12752 KB Output is correct
14 Correct 3 ms 12636 KB Output is correct
15 Correct 2 ms 12636 KB Output is correct
16 Correct 2 ms 12636 KB Output is correct
17 Correct 2 ms 12636 KB Output is correct
18 Correct 2 ms 12636 KB Output is correct
19 Correct 3 ms 12740 KB Output is correct
20 Correct 3 ms 12636 KB Output is correct
21 Incorrect 2 ms 12636 KB Output isn't correct
22 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 12636 KB Output is correct
2 Correct 2 ms 12632 KB Output is correct
3 Correct 2 ms 12636 KB Output is correct
4 Correct 2 ms 12636 KB Output is correct
5 Correct 3 ms 12748 KB Output is correct
6 Correct 2 ms 12636 KB Output is correct
7 Correct 3 ms 12736 KB Output is correct
8 Correct 2 ms 12636 KB Output is correct
9 Correct 2 ms 12632 KB Output is correct
10 Correct 2 ms 12632 KB Output is correct
11 Correct 2 ms 12632 KB Output is correct
12 Correct 2 ms 12632 KB Output is correct
13 Correct 2 ms 12636 KB Output is correct
14 Correct 2 ms 12636 KB Output is correct
15 Correct 2 ms 12632 KB Output is correct
16 Correct 2 ms 12636 KB Output is correct
17 Correct 2 ms 12632 KB Output is correct
18 Correct 2 ms 12636 KB Output is correct
19 Correct 2 ms 12636 KB Output is correct
20 Correct 2 ms 12636 KB Output is correct
21 Incorrect 2 ms 12636 KB Output isn't correct
22 Halted 0 ms 0 KB -