답안 #1080151

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1080151 2024-08-29T07:27:55 Z Trumling 말 (IOI15_horses) C++14
54 / 100
1500 ms 27748 KB
#include "horses.h"
#include<bits/stdc++.h>
using namespace std;

#define F first
#define S second
#define pb push_back
#define all(x) x.begin(),x.end()
#define INF 9999999999999999
#define MOD 1000000007
typedef long long ll;

ll n;
ll sell;
vector<int>x,y;

ll seg[2000001];

void build(int idx,int l,int r)
{
		if(l==r)
		{
			seg[idx]=x[l];
			return ;
		}
	build(idx*2,l,(l+r)/2);
	build(idx*2+1,(l+r)/2+1,r);
	seg[idx]=(seg[idx*2]*seg[idx*2+1])%MOD;
}

void update(int idx,int l,int r,int p)
{
		if(r<p || l>p)
			return ;
		
		if(l==r)
		{
			seg[idx]=x[p];
			return ;
		}
	update(idx*2,l,(l+r)/2,p);
	update(idx*2+1,(l+r)/2+1,r,p);
	seg[idx]=(seg[idx*2]*seg[idx*2+1])%MOD;
}

ll query(int idx,int L,int R,int l,int r)
{
	if(r<L || l>R)
		return 1;
	
	if(L<=l && r<=R)
		return seg[idx];
	
	return (query(idx*2,L,R,l,(l+r)/2)*query(idx*2+1,L,R,(l+r)/2+1,r))%MOD;
}

int init(int N, int X[], int Y[]) {
	n=N;
	
	
	for(int i=0;i<n;i++)
	{
		x.pb(X[i]);
		y.pb(Y[i]);
	}
	build(1,0,n-1);

	sell=n-1;
	ll curr=1;
	for(int i=n-1;i>=0;i--)
	{
		if(y[sell]*curr < y[i])
		{
			sell=i;
			curr=1;
		}
			
		
		curr*=x[i];
		if(curr*y[sell]>=MOD)
			break;
		
	}


	return (query(1,0,sell,0,n-1)*y[sell])%MOD;
}

int updateX(int pos, int val) 
{	
	x[pos]=val;
	update(1,0,n-1,pos);
	sell=n-1;
	ll curr=1;
	for(int i=n-1;i>=0;i--)
	{
		if(y[sell]*curr < y[i])
		{
			sell=i;
			curr=1;
		}
			
		
		curr*=x[i];
		if(curr*y[sell]>=MOD)
			break;
	}

	return (query(1,0,sell,0,n-1)*y[sell])%MOD;

}

int updateY(int pos, int val) {

	y[pos]=val;
	sell=n-1;
	ll curr=1;
	for(int i=n-1;i>=0;i--)
	{
		if(y[sell]*curr < y[i])
		{
			sell=i;
			curr=1;
		}
			
		
		curr*=x[i];
		if(curr*y[sell]>=MOD)
			break;
	}

	return (query(1,0,sell,0,n-1)*y[sell])%MOD;
}

Compilation message

horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:66:13: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   66 |  build(1,0,n-1);
      |            ~^~
horses.cpp:70:13: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   70 |  for(int i=n-1;i>=0;i--)
      |            ~^~
horses.cpp:86:20: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   86 |  return (query(1,0,sell,0,n-1)*y[sell])%MOD;
      |                    ^~~~
horses.cpp:86:28: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   86 |  return (query(1,0,sell,0,n-1)*y[sell])%MOD;
      |                           ~^~
horses.cpp:86:40: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   86 |  return (query(1,0,sell,0,n-1)*y[sell])%MOD;
      |                                        ^
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:92:14: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   92 |  update(1,0,n-1,pos);
      |             ~^~
horses.cpp:95:13: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   95 |  for(int i=n-1;i>=0;i--)
      |            ~^~
horses.cpp:109:20: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
  109 |  return (query(1,0,sell,0,n-1)*y[sell])%MOD;
      |                    ^~~~
horses.cpp:109:28: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
  109 |  return (query(1,0,sell,0,n-1)*y[sell])%MOD;
      |                           ~^~
horses.cpp:109:40: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
  109 |  return (query(1,0,sell,0,n-1)*y[sell])%MOD;
      |                                        ^
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:118:13: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
  118 |  for(int i=n-1;i>=0;i--)
      |            ~^~
horses.cpp:132:20: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
  132 |  return (query(1,0,sell,0,n-1)*y[sell])%MOD;
      |                    ^~~~
horses.cpp:132:28: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
  132 |  return (query(1,0,sell,0,n-1)*y[sell])%MOD;
      |                           ~^~
horses.cpp:132:40: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
  132 |  return (query(1,0,sell,0,n-1)*y[sell])%MOD;
      |                                        ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 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 344 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 344 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 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
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 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 344 KB Output is correct
16 Correct 1 ms 360 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 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 Correct 1 ms 344 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 344 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 3 ms 348 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 2 ms 348 KB Output is correct
32 Correct 2 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 51 ms 17844 KB Output is correct
2 Correct 71 ms 19416 KB Output is correct
3 Correct 45 ms 21424 KB Output is correct
4 Correct 75 ms 25608 KB Output is correct
# 결과 실행 시간 메모리 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 1 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 344 KB Output is correct
14 Correct 0 ms 344 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 Correct 0 ms 344 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 1 ms 480 KB Output is correct
29 Correct 2 ms 348 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 2 ms 344 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 55 ms 16832 KB Output is correct
34 Correct 27 ms 20664 KB Output is correct
35 Correct 55 ms 27704 KB Output is correct
36 Correct 54 ms 27744 KB Output is correct
37 Correct 412 ms 19252 KB Output is correct
38 Correct 26 ms 19900 KB Output is correct
39 Execution timed out 1524 ms 18868 KB Time limit exceeded
40 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 1 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 1 ms 344 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 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 1 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 2 ms 348 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 3 ms 348 KB Output is correct
32 Correct 1 ms 492 KB Output is correct
33 Correct 53 ms 17736 KB Output is correct
34 Correct 74 ms 19380 KB Output is correct
35 Correct 58 ms 21548 KB Output is correct
36 Correct 74 ms 25268 KB Output is correct
37 Correct 58 ms 20768 KB Output is correct
38 Correct 29 ms 20664 KB Output is correct
39 Correct 53 ms 27748 KB Output is correct
40 Correct 52 ms 27604 KB Output is correct
41 Correct 414 ms 18880 KB Output is correct
42 Correct 25 ms 19896 KB Output is correct
43 Execution timed out 1542 ms 18876 KB Time limit exceeded
44 Halted 0 ms 0 KB -