답안 #1080143

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1080143 2024-08-29T07:23:48 Z Trumling 말 (IOI15_horses) C++14
34 / 100
1500 ms 27892 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 ;
		}
	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;
}

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>=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>=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>=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 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 388 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 1 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 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 448 KB Output is correct
16 Correct 0 ms 344 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 1 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 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 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 444 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 4 ms 348 KB Output is correct
24 Correct 3 ms 508 KB Output is correct
25 Correct 4 ms 348 KB Output is correct
26 Correct 3 ms 348 KB Output is correct
27 Correct 5 ms 348 KB Output is correct
28 Correct 7 ms 508 KB Output is correct
29 Correct 10 ms 492 KB Output is correct
30 Correct 7 ms 348 KB Output is correct
31 Correct 4 ms 348 KB Output is correct
32 Correct 8 ms 456 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 66 ms 21428 KB Output is correct
2 Execution timed out 1562 ms 27704 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 380 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 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 1 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 1 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 4 ms 344 KB Output is correct
24 Correct 3 ms 348 KB Output is correct
25 Correct 4 ms 524 KB Output is correct
26 Correct 4 ms 348 KB Output is correct
27 Correct 5 ms 348 KB Output is correct
28 Correct 7 ms 348 KB Output is correct
29 Correct 10 ms 348 KB Output is correct
30 Correct 8 ms 344 KB Output is correct
31 Correct 4 ms 360 KB Output is correct
32 Correct 7 ms 348 KB Output is correct
33 Execution timed out 1550 ms 20880 KB Time limit exceeded
34 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 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 444 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 0 ms 444 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 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 4 ms 344 KB Output is correct
24 Correct 4 ms 348 KB Output is correct
25 Correct 3 ms 348 KB Output is correct
26 Correct 4 ms 348 KB Output is correct
27 Correct 4 ms 348 KB Output is correct
28 Correct 7 ms 348 KB Output is correct
29 Correct 10 ms 348 KB Output is correct
30 Correct 10 ms 656 KB Output is correct
31 Correct 5 ms 348 KB Output is correct
32 Correct 6 ms 348 KB Output is correct
33 Correct 66 ms 21612 KB Output is correct
34 Execution timed out 1504 ms 27892 KB Time limit exceeded
35 Halted 0 ms 0 KB -