답안 #28232

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
28232 2017-07-16T02:11:49 Z RayaBurong25_1 말 (IOI15_horses) C++14
17 / 100
106 ms 102788 KB
#include "horses.h"
#include <stdio.h>
#include <math.h>
#define MOD 1000000007LL
typedef struct node node;
struct node
{
	long long X, Y, Ans;
	double logX, logY, logAns;
};
node Seg[2000005];
int x[500005], y[500005];
void makeTree(int s, int e, int cell)
{
	if (s == e)
	{
		Seg[cell].X = x[s];
		Seg[cell].Y = y[s];
		Seg[cell].logX = log(x[s]);
		Seg[cell].logY = log(y[s]);
		Seg[cell].Ans = x[s];
		Seg[cell].logAns = Seg[cell].logX;
		return;
	}
	int m = (s + e)/2;
	makeTree(s, m, 2*cell + 1);
	makeTree(m + 1, e, 2*cell + 2);
	if (Seg[2*cell + 2].logAns + Seg[2*cell + 2].logY + Seg[2*cell + 1].logX > Seg[2*cell + 1].logAns + Seg[2*cell + 1].logY)
	{
		Seg[cell].X = (Seg[2*cell + 1].X*Seg[2*cell + 2].X)%MOD;
		Seg[cell].logX = Seg[2*cell + 1].logX + Seg[2*cell + 2].logX;
		Seg[cell].Y = Seg[2*cell + 2].Y;
		Seg[cell].logY = Seg[2*cell + 2].logY;
		Seg[cell].Ans = (Seg[2*cell + 1].X*Seg[2*cell + 2].Ans)%MOD;
		Seg[cell].logAns = Seg[2*cell + 1].logX + Seg[2*cell + 2].logAns;
	}
	else
	{
		Seg[cell].X = (Seg[2*cell + 1].X*Seg[2*cell + 2].X)%MOD;
		Seg[cell].logX = Seg[2*cell + 1].logX + Seg[2*cell + 2].logX;
		Seg[cell].Y = Seg[2*cell + 1].Y;
		Seg[cell].logY = Seg[2*cell + 1].logY;
		Seg[cell].Ans = Seg[2*cell + 1].Ans;
		Seg[cell].logAns = Seg[2*cell + 1].logAns;
	}
}
int n;
int init(int N, int X[], int Y[])
{
	int i;
	n = N;
	for (i = 0; i < N; i++)
		x[i] = X[i];
	for (i = 0; i < N; i++)
		y[i] = Y[i];
	makeTree(0, N - 1, 0);
	return (Seg[0].Y*Seg[0].Ans)%MOD;
}
void updX(int pos, int val, int s, int e, int cell)
{
	if (s == e)
	{
		Seg[cell].X = val;
		Seg[cell].logX = log(val);
		Seg[cell].Ans = Seg[cell].X;
		Seg[cell].logAns = Seg[cell].logX;
		return;
	}
	int m = (s + e)/2;
	if (pos <= m)
		updX(pos, val, s, m, 2*cell + 1);
	else
		updX(pos, val, m + 1, e, 2*cell + 2);
	if (Seg[2*cell + 2].logAns + Seg[2*cell + 2].logY + Seg[2*cell + 1].logX > Seg[2*cell + 1].logAns + Seg[2*cell + 1].logY)
	{
		Seg[cell].X = (Seg[2*cell + 1].X*Seg[2*cell + 2].X)%MOD;
		Seg[cell].logX = Seg[2*cell + 1].logX + Seg[2*cell + 2].logX;
		Seg[cell].Y = Seg[2*cell + 2].Y;
		Seg[cell].logY = Seg[2*cell + 2].logY;
		Seg[cell].Ans = (Seg[2*cell + 1].X*Seg[2*cell + 2].Ans)%MOD;
		Seg[cell].logAns = Seg[2*cell + 1].logX + Seg[2*cell + 2].logAns;
	}
	else
	{
		Seg[cell].X = (Seg[2*cell + 1].X*Seg[2*cell + 2].X)%MOD;
		Seg[cell].logX = Seg[2*cell + 1].logX + Seg[2*cell + 2].logX;
		Seg[cell].Y = Seg[2*cell + 1].Y;
		Seg[cell].logY = Seg[2*cell + 1].logY;
		Seg[cell].Ans = Seg[2*cell + 1].Ans;
		Seg[cell].logAns = Seg[2*cell + 1].logAns;
	}
}
int updateX(int pos, int val)
{
	updX(pos, val, 0, n - 1, 0);
	return (Seg[0].Y*Seg[0].Ans)%MOD;
}
void updY(int pos, int val, int s, int e, int cell)
{
	if (s == e)
	{
		Seg[cell].Y = val;
		Seg[cell].logY = log(val);
		return;
	}
	int m = (s + e)/2;
	if (pos <= m)
		updX(pos, val, s, m, 2*cell + 1);
	else
		updX(pos, val, m + 1, e, 2*cell + 2);
	if (Seg[2*cell + 2].logAns + Seg[2*cell + 2].logY + Seg[2*cell + 1].logX > Seg[2*cell + 1].logAns + Seg[2*cell + 1].logY)
	{
		Seg[cell].X = (Seg[2*cell + 1].X*Seg[2*cell + 2].X)%MOD;
		Seg[cell].logX = Seg[2*cell + 1].logX + Seg[2*cell + 2].logX;
		Seg[cell].Y = Seg[2*cell + 2].Y;
		Seg[cell].logY = Seg[2*cell + 2].logY;
		Seg[cell].Ans = (Seg[2*cell + 1].X*Seg[2*cell + 2].Ans)%MOD;
		Seg[cell].logAns = Seg[2*cell + 1].logX + Seg[2*cell + 2].logAns;
	}
	else
	{
		Seg[cell].X = (Seg[2*cell + 1].X*Seg[2*cell + 2].X)%MOD;
		Seg[cell].logX = Seg[2*cell + 1].logX + Seg[2*cell + 2].logX;
		Seg[cell].Y = Seg[2*cell + 1].Y;
		Seg[cell].logY = Seg[2*cell + 1].logY;
		Seg[cell].Ans = Seg[2*cell + 1].Ans;
		Seg[cell].logAns = Seg[2*cell + 1].logAns;
	}
}
int updateY(int pos, int val)
{
	updY(pos, val, 0, n - 1, 0);
	return (Seg[0].Y*Seg[0].Ans)%MOD;
}

Compilation message

horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:4:13: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
 #define MOD 1000000007LL
             ^
horses.cpp:57:31: note: in expansion of macro 'MOD'
  return (Seg[0].Y*Seg[0].Ans)%MOD;
                               ^
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:4:13: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
 #define MOD 1000000007LL
             ^
horses.cpp:96:31: note: in expansion of macro 'MOD'
  return (Seg[0].Y*Seg[0].Ans)%MOD;
                               ^
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:4:13: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
 #define MOD 1000000007LL
             ^
horses.cpp:133:31: note: in expansion of macro 'MOD'
  return (Seg[0].Y*Seg[0].Ans)%MOD;
                               ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 98876 KB Output is correct
2 Correct 0 ms 98876 KB Output is correct
3 Correct 0 ms 98876 KB Output is correct
4 Correct 0 ms 98876 KB Output is correct
5 Correct 0 ms 98876 KB Output is correct
6 Correct 0 ms 98876 KB Output is correct
7 Correct 0 ms 98876 KB Output is correct
8 Correct 0 ms 98876 KB Output is correct
9 Correct 0 ms 98876 KB Output is correct
10 Correct 0 ms 98876 KB Output is correct
11 Correct 0 ms 98876 KB Output is correct
12 Correct 0 ms 98876 KB Output is correct
13 Correct 0 ms 98876 KB Output is correct
14 Correct 0 ms 98876 KB Output is correct
15 Correct 0 ms 98876 KB Output is correct
16 Correct 0 ms 98876 KB Output is correct
17 Correct 0 ms 98876 KB Output is correct
18 Correct 0 ms 98876 KB Output is correct
19 Correct 0 ms 98876 KB Output is correct
20 Correct 0 ms 98876 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 98876 KB Output is correct
2 Correct 0 ms 98876 KB Output is correct
3 Correct 0 ms 98876 KB Output is correct
4 Correct 0 ms 98876 KB Output is correct
5 Correct 0 ms 98876 KB Output is correct
6 Correct 0 ms 98876 KB Output is correct
7 Correct 0 ms 98876 KB Output is correct
8 Correct 0 ms 98876 KB Output is correct
9 Correct 0 ms 98876 KB Output is correct
10 Correct 0 ms 98876 KB Output is correct
11 Correct 0 ms 98876 KB Output is correct
12 Correct 0 ms 98876 KB Output is correct
13 Correct 0 ms 98876 KB Output is correct
14 Correct 0 ms 98876 KB Output is correct
15 Correct 0 ms 98876 KB Output is correct
16 Correct 0 ms 98876 KB Output is correct
17 Correct 0 ms 98876 KB Output is correct
18 Correct 0 ms 98876 KB Output is correct
19 Correct 0 ms 98876 KB Output is correct
20 Correct 0 ms 98876 KB Output is correct
21 Incorrect 0 ms 98876 KB Output isn't correct
22 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 106 ms 102788 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 98876 KB Output is correct
2 Correct 0 ms 98876 KB Output is correct
3 Correct 0 ms 98876 KB Output is correct
4 Correct 0 ms 98876 KB Output is correct
5 Correct 0 ms 98876 KB Output is correct
6 Correct 0 ms 98876 KB Output is correct
7 Correct 0 ms 98876 KB Output is correct
8 Correct 0 ms 98876 KB Output is correct
9 Correct 0 ms 98876 KB Output is correct
10 Correct 0 ms 98876 KB Output is correct
11 Correct 0 ms 98876 KB Output is correct
12 Correct 0 ms 98876 KB Output is correct
13 Correct 0 ms 98876 KB Output is correct
14 Correct 0 ms 98876 KB Output is correct
15 Correct 0 ms 98876 KB Output is correct
16 Correct 0 ms 98876 KB Output is correct
17 Correct 0 ms 98876 KB Output is correct
18 Correct 0 ms 98876 KB Output is correct
19 Correct 0 ms 98876 KB Output is correct
20 Correct 0 ms 98876 KB Output is correct
21 Incorrect 0 ms 98876 KB Output isn't correct
22 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 98876 KB Output is correct
2 Correct 0 ms 98876 KB Output is correct
3 Correct 0 ms 98876 KB Output is correct
4 Correct 0 ms 98876 KB Output is correct
5 Correct 0 ms 98876 KB Output is correct
6 Correct 0 ms 98876 KB Output is correct
7 Correct 0 ms 98876 KB Output is correct
8 Correct 0 ms 98876 KB Output is correct
9 Correct 0 ms 98876 KB Output is correct
10 Correct 0 ms 98876 KB Output is correct
11 Correct 0 ms 98876 KB Output is correct
12 Correct 0 ms 98876 KB Output is correct
13 Correct 0 ms 98876 KB Output is correct
14 Correct 0 ms 98876 KB Output is correct
15 Correct 0 ms 98876 KB Output is correct
16 Correct 0 ms 98876 KB Output is correct
17 Correct 0 ms 98876 KB Output is correct
18 Correct 0 ms 98876 KB Output is correct
19 Correct 0 ms 98876 KB Output is correct
20 Correct 0 ms 98876 KB Output is correct
21 Incorrect 0 ms 98876 KB Output isn't correct
22 Halted 0 ms 0 KB -