답안 #830339

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
830339 2023-08-19T03:59:31 Z Supersonic 말 (IOI15_horses) C++14
54 / 100
1500 ms 33416 KB
#include "horses.h"
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
ll h[500001];
ll x[500001];
ll y[500001];
bool subtask3=1;
int n;
ll tree[1048577];
void modify(int k, int x) {
	k += n;
	tree[k] = x;
	for (k /= 2; k >= 1; k /= 2) {
		tree[k] = tree[2*k]*tree[2*k+1];
		tree[k]%=((ll)1e9+7);
	}
}

ll prod(ll a, ll b) {
	a += n; b += n;
	ll s = 1;
	while (a <= b) {
		if (a%2 == 1) {s *= tree[a++];s%=((ll)1e9+7);}
		if (b%2 == 0) {s *= tree[b--];s%=((ll)1e9+7);}
		a /= 2; b /= 2;
	}
	return s;
}

int init(int N, int X[], int Y[]) {
	n=N;
	if(n<=1000)subtask3=0;
	for(int i=0;i<n;i++){
		x[i]=X[i];
		if(x[i]<2)subtask3=0;
		modify(i,x[i]);
		y[i]=Y[i];
	}
	//if(subtask3)exit(1);
	//cout<<prod(0,2)<<endl;;
	if(!subtask3){
		ll mp=0;ll c=1;
		for(int i=1;i<n;i++){
			c*=x[i];
			if(c>y[mp]||y[i]>y[mp]||c*y[i]>y[mp]){mp=i;c=1;}
		}
		return (prod(0,mp)*y[mp])%((ll)1e9+7);
	}
	else{
		ll mp=n-33;ll c=1;
		for(int i=n-32;i<n;i++){
			c*=x[i];
			if(c>y[mp]||y[i]>y[mp]||c*y[i]>y[mp]){mp=i;c=1;}
		}
		return (prod(0,mp)*y[mp])%((ll)1e9+7);
	}
}
 
int updateX(int pos, int val) {	
	if(!subtask3){
		x[pos]=val;
		modify(pos,val);
		ll mp=0;ll c=1;
		for(int i=1;i<n;i++){
			c*=x[i];
			if(c>y[mp]||y[i]>y[mp]||c*y[i]>y[mp]){mp=i;c=1;}
		}
		return (prod(0,mp)*y[mp])%((ll)1e9+7);
	}
	else{
		x[pos]=val;
		modify(pos,val);
		ll mp=n-33;ll c=1;
		for(int i=n-32;i<n;i++){
			c*=x[i];
			if(c>y[mp]||y[i]>y[mp]||c*y[i]>y[mp]){mp=i;c=1;}
		}
		return (prod(0,mp)*y[mp])%((ll)1e9+7);
	}
	
}
 
int updateY(int pos, int val) {
	if(!subtask3){
		y[pos]=val;
		ll mp=0;ll c=1;
		for(int i=1;i<n;i++){
			c*=x[i];
			if(c>y[mp]||y[i]>y[mp]||c*y[i]>y[mp]){mp=i;c=1;}
		}
		return (prod(0,mp)*y[mp])%((ll)1e9+7);
	}
	else{
		y[pos]=val;
		ll mp=33;ll c=1;
		for(int i=n-32;i<n;i++){
			c*=x[i];
			if(c>y[mp]||y[i]>y[mp]||c*y[i]>y[mp]){mp=i;c=1;}
		}
		return (prod(0,mp)*y[mp])%((ll)1e9+7);
	}
}

Compilation message

horses.cpp: In function 'void modify(int, int)':
horses.cpp:11:24: warning: declaration of 'x' shadows a global declaration [-Wshadow]
   11 | void modify(int k, int x) {
      |                    ~~~~^
horses.cpp:6:4: note: shadowed declaration is here
    6 | ll x[500001];
      |    ^
horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:37:15: warning: conversion from 'll' {aka 'long long unsigned int'} to 'int' may change value [-Wconversion]
   37 |   modify(i,x[i]);
      |            ~~~^
horses.cpp:48:28: warning: conversion from 'll' {aka 'long long unsigned int'} to 'int' may change value [-Wconversion]
   48 |   return (prod(0,mp)*y[mp])%((ll)1e9+7);
      |          ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~
horses.cpp:56:28: warning: conversion from 'll' {aka 'long long unsigned int'} to 'int' may change value [-Wconversion]
   56 |   return (prod(0,mp)*y[mp])%((ll)1e9+7);
      |          ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:69:28: warning: conversion from 'll' {aka 'long long unsigned int'} to 'int' may change value [-Wconversion]
   69 |   return (prod(0,mp)*y[mp])%((ll)1e9+7);
      |          ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~
horses.cpp:79:28: warning: conversion from 'll' {aka 'long long unsigned int'} to 'int' may change value [-Wconversion]
   79 |   return (prod(0,mp)*y[mp])%((ll)1e9+7);
      |          ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:92:28: warning: conversion from 'll' {aka 'long long unsigned int'} to 'int' may change value [-Wconversion]
   92 |   return (prod(0,mp)*y[mp])%((ll)1e9+7);
      |          ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~
horses.cpp:101:28: warning: conversion from 'll' {aka 'long long unsigned int'} to 'int' may change value [-Wconversion]
  101 |   return (prod(0,mp)*y[mp])%((ll)1e9+7);
      |          ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 256 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 3 ms 340 KB Output is correct
24 Correct 2 ms 340 KB Output is correct
25 Correct 4 ms 340 KB Output is correct
26 Correct 3 ms 340 KB Output is correct
27 Correct 3 ms 340 KB Output is correct
28 Correct 2 ms 340 KB Output is correct
29 Correct 3 ms 340 KB Output is correct
30 Correct 2 ms 340 KB Output is correct
31 Correct 3 ms 340 KB Output is correct
32 Correct 3 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 86 ms 20812 KB Output is correct
2 Correct 124 ms 20776 KB Output is correct
3 Correct 91 ms 20820 KB Output is correct
4 Correct 111 ms 20792 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 2 ms 340 KB Output is correct
24 Correct 2 ms 340 KB Output is correct
25 Correct 3 ms 340 KB Output is correct
26 Correct 4 ms 340 KB Output is correct
27 Correct 3 ms 368 KB Output is correct
28 Correct 2 ms 340 KB Output is correct
29 Correct 3 ms 340 KB Output is correct
30 Correct 2 ms 340 KB Output is correct
31 Correct 3 ms 340 KB Output is correct
32 Correct 3 ms 340 KB Output is correct
33 Execution timed out 1581 ms 19884 KB Time limit exceeded
34 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 2 ms 340 KB Output is correct
24 Correct 2 ms 340 KB Output is correct
25 Correct 3 ms 340 KB Output is correct
26 Correct 3 ms 340 KB Output is correct
27 Correct 3 ms 340 KB Output is correct
28 Correct 2 ms 340 KB Output is correct
29 Correct 3 ms 364 KB Output is correct
30 Correct 2 ms 360 KB Output is correct
31 Correct 3 ms 340 KB Output is correct
32 Correct 4 ms 368 KB Output is correct
33 Correct 86 ms 22316 KB Output is correct
34 Correct 124 ms 33416 KB Output is correct
35 Correct 89 ms 24620 KB Output is correct
36 Correct 132 ms 28504 KB Output is correct
37 Execution timed out 1575 ms 23820 KB Time limit exceeded
38 Halted 0 ms 0 KB -