# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
333413 |
2020-12-05T21:53:37 Z |
errorgorn |
Horses (IOI15_horses) |
C++17 |
|
273 ms |
103916 KB |
//雪花飄飄北風嘯嘯
//天地一片蒼茫
#include "horses.h"
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
#define ll long long
#define ii pair<ll,ll>
#define iii pair<ii,ll>
#define fi first
#define se second
#define endl '\n'
#define debug(x) cout << #x << " is " << x << endl
#define rep(x,start,end) for(auto x=(start)-((start)>(end));x!=(end)-((start)>(end));((start)<(end)?x++:x--))
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define indexed_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>
//change less to less_equal for non distinct pbds, but erase will bug
const int MOD=1000000007;
ll qexp(ll b,ll p,int m){
ll res=1;
while (p){
if (p&1) res=res*b%m;
b=b*b%m;
p>>=1;
}
return res;
}
ll inv(ll i){
return qexp(i,MOD-2,MOD);
}
ll arr[500005];
ll brr[500005];
struct node{
int s,e,m;
ll val;
bool over=false;
ll num,denom;
node *l,*r;
void mx(ll num2,ll denom2){
if (num2*denom>num*denom2){
num=num2;
denom=denom2;
}
}
void init(){
val=arr[s];
num=brr[s],denom=1;
}
void comb(){
val=l->val*r->val;
over=l->over|r->over;
if (val>MOD){
val%=MOD;
over=true;
}
if (!r->over) num=brr[m],denom=r->val;
else num=0,denom=1;
mx(r->num,r->denom);
if (!r->over && r->val*l->denom<MOD) mx(l->num,r->val*l->denom);
}
node (int _s,int _e){
s=_s,e=_e,m=s+e>>1;
if (s!=e){
l=new node(s,m);
r=new node(m+1,e);
comb();
}
else{
init();
}
}
void update(int i){
if (s==e) {
init();
return;
}
if (i<=m) l->update(i);
else r->update(i);
comb();
}
} *root;
int init(int n, int X[], int Y[]) {
rep(x,0,n) arr[x]=X[x];
rep(x,0,n) brr[x]=Y[x];
root=new node(0,n-1);
return root->val*root->num%MOD*inv(root->denom)%MOD;
}
int updateX(int pos, int val) {
arr[pos]=val;
root->update(pos);
return root->val*root->num%MOD*inv(root->denom)%MOD;
}
int updateY(int pos, int val) {
brr[pos]=val;
root->update(pos);
return root->val*root->num%MOD*inv(root->denom)%MOD;
}
Compilation message
horses.cpp: In constructor 'node::node(int, int)':
horses.cpp:82:16: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
82 | s=_s,e=_e,m=s+e>>1;
| ~^~
horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:113:49: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
113 | return root->val*root->num%MOD*inv(root->denom)%MOD;
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:120:49: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
120 | return root->val*root->num%MOD*inv(root->denom)%MOD;
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:127:49: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
127 | return root->val*root->num%MOD*inv(root->denom)%MOD;
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
10 |
Correct |
0 ms |
364 KB |
Output is correct |
11 |
Correct |
1 ms |
364 KB |
Output is correct |
12 |
Correct |
0 ms |
364 KB |
Output is correct |
13 |
Correct |
1 ms |
364 KB |
Output is correct |
14 |
Correct |
1 ms |
364 KB |
Output is correct |
15 |
Correct |
1 ms |
364 KB |
Output is correct |
16 |
Correct |
1 ms |
364 KB |
Output is correct |
17 |
Correct |
1 ms |
364 KB |
Output is correct |
18 |
Correct |
1 ms |
364 KB |
Output is correct |
19 |
Correct |
1 ms |
364 KB |
Output is correct |
20 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
10 |
Correct |
1 ms |
364 KB |
Output is correct |
11 |
Correct |
1 ms |
364 KB |
Output is correct |
12 |
Correct |
1 ms |
364 KB |
Output is correct |
13 |
Correct |
1 ms |
364 KB |
Output is correct |
14 |
Correct |
1 ms |
364 KB |
Output is correct |
15 |
Correct |
1 ms |
364 KB |
Output is correct |
16 |
Correct |
1 ms |
364 KB |
Output is correct |
17 |
Correct |
1 ms |
364 KB |
Output is correct |
18 |
Correct |
1 ms |
364 KB |
Output is correct |
19 |
Correct |
1 ms |
364 KB |
Output is correct |
20 |
Correct |
1 ms |
364 KB |
Output is correct |
21 |
Correct |
1 ms |
364 KB |
Output is correct |
22 |
Correct |
1 ms |
364 KB |
Output is correct |
23 |
Correct |
1 ms |
620 KB |
Output is correct |
24 |
Correct |
1 ms |
620 KB |
Output is correct |
25 |
Correct |
1 ms |
620 KB |
Output is correct |
26 |
Correct |
1 ms |
620 KB |
Output is correct |
27 |
Correct |
1 ms |
492 KB |
Output is correct |
28 |
Correct |
1 ms |
492 KB |
Output is correct |
29 |
Correct |
1 ms |
492 KB |
Output is correct |
30 |
Correct |
1 ms |
620 KB |
Output is correct |
31 |
Correct |
1 ms |
492 KB |
Output is correct |
32 |
Correct |
1 ms |
492 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
141 ms |
95140 KB |
Output is correct |
2 |
Correct |
273 ms |
103916 KB |
Output is correct |
3 |
Correct |
242 ms |
95084 KB |
Output is correct |
4 |
Correct |
251 ms |
99052 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
10 |
Correct |
1 ms |
364 KB |
Output is correct |
11 |
Correct |
1 ms |
364 KB |
Output is correct |
12 |
Correct |
1 ms |
364 KB |
Output is correct |
13 |
Correct |
1 ms |
364 KB |
Output is correct |
14 |
Correct |
1 ms |
364 KB |
Output is correct |
15 |
Correct |
1 ms |
364 KB |
Output is correct |
16 |
Correct |
1 ms |
364 KB |
Output is correct |
17 |
Correct |
1 ms |
364 KB |
Output is correct |
18 |
Correct |
1 ms |
364 KB |
Output is correct |
19 |
Correct |
1 ms |
364 KB |
Output is correct |
20 |
Correct |
1 ms |
364 KB |
Output is correct |
21 |
Correct |
1 ms |
364 KB |
Output is correct |
22 |
Correct |
1 ms |
364 KB |
Output is correct |
23 |
Correct |
1 ms |
620 KB |
Output is correct |
24 |
Correct |
1 ms |
620 KB |
Output is correct |
25 |
Correct |
1 ms |
620 KB |
Output is correct |
26 |
Correct |
2 ms |
620 KB |
Output is correct |
27 |
Correct |
1 ms |
492 KB |
Output is correct |
28 |
Correct |
1 ms |
492 KB |
Output is correct |
29 |
Correct |
1 ms |
492 KB |
Output is correct |
30 |
Correct |
1 ms |
620 KB |
Output is correct |
31 |
Correct |
1 ms |
492 KB |
Output is correct |
32 |
Correct |
1 ms |
492 KB |
Output is correct |
33 |
Correct |
115 ms |
94316 KB |
Output is correct |
34 |
Correct |
114 ms |
94316 KB |
Output is correct |
35 |
Correct |
131 ms |
101356 KB |
Output is correct |
36 |
Correct |
129 ms |
101356 KB |
Output is correct |
37 |
Correct |
100 ms |
92524 KB |
Output is correct |
38 |
Correct |
97 ms |
93420 KB |
Output is correct |
39 |
Correct |
89 ms |
92396 KB |
Output is correct |
40 |
Correct |
108 ms |
96364 KB |
Output is correct |
41 |
Correct |
90 ms |
92524 KB |
Output is correct |
42 |
Correct |
88 ms |
92524 KB |
Output is correct |
43 |
Correct |
103 ms |
96748 KB |
Output is correct |
44 |
Correct |
106 ms |
96776 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
10 |
Correct |
1 ms |
364 KB |
Output is correct |
11 |
Correct |
1 ms |
364 KB |
Output is correct |
12 |
Correct |
1 ms |
364 KB |
Output is correct |
13 |
Correct |
1 ms |
364 KB |
Output is correct |
14 |
Correct |
1 ms |
364 KB |
Output is correct |
15 |
Correct |
1 ms |
364 KB |
Output is correct |
16 |
Correct |
1 ms |
364 KB |
Output is correct |
17 |
Correct |
1 ms |
364 KB |
Output is correct |
18 |
Correct |
1 ms |
364 KB |
Output is correct |
19 |
Correct |
1 ms |
364 KB |
Output is correct |
20 |
Correct |
1 ms |
364 KB |
Output is correct |
21 |
Correct |
1 ms |
364 KB |
Output is correct |
22 |
Correct |
1 ms |
364 KB |
Output is correct |
23 |
Correct |
1 ms |
620 KB |
Output is correct |
24 |
Correct |
1 ms |
620 KB |
Output is correct |
25 |
Correct |
1 ms |
620 KB |
Output is correct |
26 |
Correct |
1 ms |
620 KB |
Output is correct |
27 |
Correct |
1 ms |
492 KB |
Output is correct |
28 |
Correct |
1 ms |
492 KB |
Output is correct |
29 |
Correct |
1 ms |
492 KB |
Output is correct |
30 |
Correct |
1 ms |
620 KB |
Output is correct |
31 |
Correct |
1 ms |
492 KB |
Output is correct |
32 |
Correct |
1 ms |
492 KB |
Output is correct |
33 |
Correct |
140 ms |
95212 KB |
Output is correct |
34 |
Correct |
270 ms |
103916 KB |
Output is correct |
35 |
Correct |
232 ms |
95084 KB |
Output is correct |
36 |
Correct |
248 ms |
98924 KB |
Output is correct |
37 |
Correct |
112 ms |
94444 KB |
Output is correct |
38 |
Correct |
110 ms |
94316 KB |
Output is correct |
39 |
Correct |
128 ms |
101356 KB |
Output is correct |
40 |
Correct |
128 ms |
101356 KB |
Output is correct |
41 |
Correct |
98 ms |
92524 KB |
Output is correct |
42 |
Correct |
95 ms |
93420 KB |
Output is correct |
43 |
Correct |
86 ms |
92396 KB |
Output is correct |
44 |
Correct |
107 ms |
96364 KB |
Output is correct |
45 |
Correct |
88 ms |
92524 KB |
Output is correct |
46 |
Correct |
87 ms |
92524 KB |
Output is correct |
47 |
Correct |
104 ms |
96768 KB |
Output is correct |
48 |
Correct |
101 ms |
96748 KB |
Output is correct |
49 |
Correct |
251 ms |
96492 KB |
Output is correct |
50 |
Correct |
251 ms |
96364 KB |
Output is correct |
51 |
Correct |
171 ms |
103148 KB |
Output is correct |
52 |
Correct |
172 ms |
102636 KB |
Output is correct |
53 |
Correct |
235 ms |
94700 KB |
Output is correct |
54 |
Correct |
150 ms |
95340 KB |
Output is correct |
55 |
Correct |
135 ms |
93548 KB |
Output is correct |
56 |
Correct |
156 ms |
98156 KB |
Output is correct |
57 |
Correct |
132 ms |
94060 KB |
Output is correct |
58 |
Correct |
132 ms |
94652 KB |
Output is correct |
59 |
Correct |
101 ms |
96748 KB |
Output is correct |