# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
56237 |
2018-07-10T13:05:27 Z |
WA_TLE |
Horses (IOI15_horses) |
C++14 |
|
258 ms |
280604 KB |
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<horses.h>
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*
cout<<setprecision(20)
cin.tie(0);
ios::sync_with_stdio(false);
*/
const llint mod=1e9+7;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
//llint lcm(llint a,llint b){return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
//hourses
//セグ木
//doubleでも足りないのでlogを累積和する
//すると、「セグメントのx」、「セグメントのy」、があるので更新する
int n;
static double segx[1048576];
static double segy[1048576];
static llint modx[1048576];
static llint mody[1048576];
vector<llint>mtoy;
int init(int N,int X[],int Y[]){
n=N;
mtoy.res(N);
int i;
for(i=0;i<n;i++){mtoy[i]=Y[i];}
for(i=(1<<19);i<(1<<19)+N;i++){
segx[i]=log(X[i-(1<<19)]);
segy[i]=log(X[i-(1<<19)])+log(Y[i-(1<<19)]);
modx[i]=X[i-(1<<19)];
mody[i]=(((llint)Y[i-(1<<19)])*X[i-(1<<19)])%mod;
}
for(i=(1<<19)+N;i<(1<<20);i++){segx[i]=-big;segy[i]=-big;mody[i]=0;modx[i]=0;}
for(i=(1<<19)-1;i>0;i--){
segx[i]=segx[i+i]+segx[i+i+1];
modx[i]=(modx[i+i]*modx[i+i+1])%mod;
if(segy[i+i]>segx[i+i]+segy[i+i+1]){
segy[i]=segy[i+i];
mody[i]=mody[i+i];
}else{
segy[i]=segx[i+i]+segy[i+i+1];
mody[i]=(modx[i+i]*mody[i+i+1])%mod;
}
}
return mody[1];
}
int updateX(int pos,int val){
pos+=(1<<19);
segy[pos]=log(mtoy[pos-(1<<19)])+log(val);
segx[pos]=log(val);
mody[pos]=(mtoy[pos-(1<<19)]*val)%mod;
modx[pos]=val;
pos/=2;
while(pos>0){
segx[pos]=segx[pos+pos]+segx[pos+pos+1];
modx[pos]=(modx[pos+pos]*modx[pos+pos+1])%mod;
if(segy[pos+pos]>segx[pos+pos]+segy[pos+pos+1]){
segy[pos]=segy[pos+pos];
mody[pos]=mody[pos+pos];
}else{
segy[pos]=segx[pos+pos]+segy[pos+pos+1];
mody[pos]=(modx[pos+pos]*mody[pos+pos+1])%mod;
}
pos/=2;
}
return mody[1];
}
int updateY(int pos,int val){
pos+=(1<<19);
segy[pos]=segx[pos]+log(val);
mody[pos]=(modx[pos]*val)%mod;
mtoy[pos-(1<<19)]=val;
pos/=2;
while(pos>0){
segx[pos]=segx[pos+pos]+segx[pos+pos+1];
modx[pos]=(modx[pos+pos]*modx[pos+pos+1])%mod;
if(segy[pos+pos]>segx[pos+pos]+segy[pos+pos+1]){
segy[pos]=segy[pos+pos];
mody[pos]=mody[pos+pos];
}else{
segy[pos]=segx[pos+pos]+segy[pos+pos+1];
mody[pos]=(modx[pos+pos]*mody[pos+pos+1])%mod;
}
pos/=2;
}
return mody[1];
}
Compilation message
horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:87:15: warning: conversion to 'int' from 'llint {aka long long int}' may alter its value [-Wconversion]
return mody[1];
~~~~~~^
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:108:15: warning: conversion to 'int' from 'llint {aka long long int}' may alter its value [-Wconversion]
return mody[1];
~~~~~~^
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:129:15: warning: conversion to 'int' from 'llint {aka long long int}' may alter its value [-Wconversion]
return mody[1];
~~~~~~^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
31 ms |
33272 KB |
Output is correct |
2 |
Correct |
32 ms |
33388 KB |
Output is correct |
3 |
Correct |
31 ms |
33388 KB |
Output is correct |
4 |
Correct |
29 ms |
33520 KB |
Output is correct |
5 |
Correct |
30 ms |
33520 KB |
Output is correct |
6 |
Correct |
28 ms |
33540 KB |
Output is correct |
7 |
Correct |
29 ms |
33560 KB |
Output is correct |
8 |
Correct |
34 ms |
33560 KB |
Output is correct |
9 |
Correct |
30 ms |
33868 KB |
Output is correct |
10 |
Correct |
38 ms |
33868 KB |
Output is correct |
11 |
Correct |
30 ms |
33868 KB |
Output is correct |
12 |
Correct |
39 ms |
33868 KB |
Output is correct |
13 |
Correct |
37 ms |
33868 KB |
Output is correct |
14 |
Correct |
35 ms |
33868 KB |
Output is correct |
15 |
Correct |
34 ms |
33868 KB |
Output is correct |
16 |
Correct |
28 ms |
33868 KB |
Output is correct |
17 |
Correct |
32 ms |
33868 KB |
Output is correct |
18 |
Correct |
30 ms |
33868 KB |
Output is correct |
19 |
Correct |
29 ms |
33868 KB |
Output is correct |
20 |
Correct |
28 ms |
33868 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
30 ms |
33868 KB |
Output is correct |
2 |
Correct |
37 ms |
33868 KB |
Output is correct |
3 |
Correct |
30 ms |
33868 KB |
Output is correct |
4 |
Correct |
29 ms |
33868 KB |
Output is correct |
5 |
Correct |
39 ms |
34128 KB |
Output is correct |
6 |
Correct |
30 ms |
34128 KB |
Output is correct |
7 |
Correct |
34 ms |
34128 KB |
Output is correct |
8 |
Correct |
34 ms |
34128 KB |
Output is correct |
9 |
Correct |
34 ms |
34128 KB |
Output is correct |
10 |
Correct |
32 ms |
34128 KB |
Output is correct |
11 |
Correct |
30 ms |
34128 KB |
Output is correct |
12 |
Correct |
34 ms |
34128 KB |
Output is correct |
13 |
Correct |
30 ms |
34128 KB |
Output is correct |
14 |
Correct |
38 ms |
34128 KB |
Output is correct |
15 |
Correct |
33 ms |
34128 KB |
Output is correct |
16 |
Correct |
29 ms |
34128 KB |
Output is correct |
17 |
Correct |
34 ms |
34128 KB |
Output is correct |
18 |
Correct |
30 ms |
34128 KB |
Output is correct |
19 |
Correct |
31 ms |
34128 KB |
Output is correct |
20 |
Correct |
29 ms |
34128 KB |
Output is correct |
21 |
Correct |
29 ms |
34128 KB |
Output is correct |
22 |
Correct |
36 ms |
34128 KB |
Output is correct |
23 |
Correct |
31 ms |
34128 KB |
Output is correct |
24 |
Correct |
37 ms |
34128 KB |
Output is correct |
25 |
Correct |
31 ms |
34128 KB |
Output is correct |
26 |
Correct |
32 ms |
34128 KB |
Output is correct |
27 |
Correct |
31 ms |
34128 KB |
Output is correct |
28 |
Correct |
31 ms |
34128 KB |
Output is correct |
29 |
Correct |
29 ms |
34156 KB |
Output is correct |
30 |
Correct |
31 ms |
34156 KB |
Output is correct |
31 |
Correct |
34 ms |
34180 KB |
Output is correct |
32 |
Correct |
29 ms |
34180 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
120 ms |
46724 KB |
Output is correct |
2 |
Correct |
258 ms |
59472 KB |
Output is correct |
3 |
Correct |
189 ms |
63264 KB |
Output is correct |
4 |
Correct |
257 ms |
70916 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
34 ms |
70916 KB |
Output is correct |
2 |
Correct |
36 ms |
70916 KB |
Output is correct |
3 |
Correct |
28 ms |
70916 KB |
Output is correct |
4 |
Correct |
29 ms |
70916 KB |
Output is correct |
5 |
Correct |
31 ms |
70916 KB |
Output is correct |
6 |
Correct |
34 ms |
70916 KB |
Output is correct |
7 |
Correct |
34 ms |
70916 KB |
Output is correct |
8 |
Correct |
30 ms |
70916 KB |
Output is correct |
9 |
Correct |
32 ms |
70916 KB |
Output is correct |
10 |
Correct |
34 ms |
70916 KB |
Output is correct |
11 |
Correct |
37 ms |
70916 KB |
Output is correct |
12 |
Correct |
32 ms |
70916 KB |
Output is correct |
13 |
Correct |
29 ms |
70916 KB |
Output is correct |
14 |
Correct |
30 ms |
70916 KB |
Output is correct |
15 |
Correct |
35 ms |
70916 KB |
Output is correct |
16 |
Correct |
35 ms |
70916 KB |
Output is correct |
17 |
Correct |
34 ms |
70916 KB |
Output is correct |
18 |
Correct |
34 ms |
70916 KB |
Output is correct |
19 |
Correct |
35 ms |
70916 KB |
Output is correct |
20 |
Correct |
32 ms |
70916 KB |
Output is correct |
21 |
Correct |
30 ms |
70916 KB |
Output is correct |
22 |
Correct |
33 ms |
70916 KB |
Output is correct |
23 |
Correct |
35 ms |
70916 KB |
Output is correct |
24 |
Correct |
30 ms |
70916 KB |
Output is correct |
25 |
Correct |
36 ms |
70916 KB |
Output is correct |
26 |
Correct |
30 ms |
70916 KB |
Output is correct |
27 |
Correct |
30 ms |
70916 KB |
Output is correct |
28 |
Correct |
30 ms |
70916 KB |
Output is correct |
29 |
Correct |
31 ms |
70916 KB |
Output is correct |
30 |
Correct |
29 ms |
70916 KB |
Output is correct |
31 |
Correct |
33 ms |
70916 KB |
Output is correct |
32 |
Correct |
30 ms |
70916 KB |
Output is correct |
33 |
Correct |
95 ms |
74260 KB |
Output is correct |
34 |
Correct |
112 ms |
78140 KB |
Output is correct |
35 |
Correct |
157 ms |
89032 KB |
Output is correct |
36 |
Correct |
157 ms |
99920 KB |
Output is correct |
37 |
Correct |
84 ms |
102032 KB |
Output is correct |
38 |
Correct |
99 ms |
105032 KB |
Output is correct |
39 |
Correct |
54 ms |
106908 KB |
Output is correct |
40 |
Correct |
128 ms |
112928 KB |
Output is correct |
41 |
Correct |
57 ms |
115008 KB |
Output is correct |
42 |
Correct |
58 ms |
117304 KB |
Output is correct |
43 |
Correct |
116 ms |
123648 KB |
Output is correct |
44 |
Correct |
98 ms |
129856 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
30 ms |
129856 KB |
Output is correct |
2 |
Correct |
30 ms |
129856 KB |
Output is correct |
3 |
Correct |
36 ms |
129856 KB |
Output is correct |
4 |
Correct |
34 ms |
129856 KB |
Output is correct |
5 |
Correct |
31 ms |
129856 KB |
Output is correct |
6 |
Correct |
29 ms |
129856 KB |
Output is correct |
7 |
Correct |
33 ms |
129856 KB |
Output is correct |
8 |
Correct |
30 ms |
129856 KB |
Output is correct |
9 |
Correct |
36 ms |
129856 KB |
Output is correct |
10 |
Correct |
34 ms |
129856 KB |
Output is correct |
11 |
Correct |
34 ms |
129856 KB |
Output is correct |
12 |
Correct |
34 ms |
129856 KB |
Output is correct |
13 |
Correct |
29 ms |
129856 KB |
Output is correct |
14 |
Correct |
29 ms |
129856 KB |
Output is correct |
15 |
Correct |
31 ms |
129856 KB |
Output is correct |
16 |
Correct |
33 ms |
129856 KB |
Output is correct |
17 |
Correct |
37 ms |
129856 KB |
Output is correct |
18 |
Correct |
28 ms |
129856 KB |
Output is correct |
19 |
Correct |
29 ms |
129856 KB |
Output is correct |
20 |
Correct |
28 ms |
129856 KB |
Output is correct |
21 |
Correct |
29 ms |
129856 KB |
Output is correct |
22 |
Correct |
29 ms |
129856 KB |
Output is correct |
23 |
Correct |
33 ms |
129856 KB |
Output is correct |
24 |
Correct |
31 ms |
129856 KB |
Output is correct |
25 |
Correct |
38 ms |
129856 KB |
Output is correct |
26 |
Correct |
30 ms |
129856 KB |
Output is correct |
27 |
Correct |
32 ms |
129856 KB |
Output is correct |
28 |
Correct |
36 ms |
129856 KB |
Output is correct |
29 |
Correct |
31 ms |
129856 KB |
Output is correct |
30 |
Correct |
32 ms |
129856 KB |
Output is correct |
31 |
Correct |
30 ms |
129856 KB |
Output is correct |
32 |
Correct |
32 ms |
129856 KB |
Output is correct |
33 |
Correct |
139 ms |
134920 KB |
Output is correct |
34 |
Correct |
251 ms |
147680 KB |
Output is correct |
35 |
Correct |
182 ms |
151388 KB |
Output is correct |
36 |
Correct |
247 ms |
159060 KB |
Output is correct |
37 |
Correct |
98 ms |
162116 KB |
Output is correct |
38 |
Correct |
93 ms |
165984 KB |
Output is correct |
39 |
Correct |
130 ms |
176836 KB |
Output is correct |
40 |
Correct |
150 ms |
187788 KB |
Output is correct |
41 |
Correct |
70 ms |
189708 KB |
Output is correct |
42 |
Correct |
89 ms |
192832 KB |
Output is correct |
43 |
Correct |
58 ms |
194692 KB |
Output is correct |
44 |
Correct |
116 ms |
200728 KB |
Output is correct |
45 |
Correct |
70 ms |
202808 KB |
Output is correct |
46 |
Correct |
60 ms |
204932 KB |
Output is correct |
47 |
Correct |
109 ms |
211156 KB |
Output is correct |
48 |
Correct |
110 ms |
217708 KB |
Output is correct |
49 |
Correct |
225 ms |
223700 KB |
Output is correct |
50 |
Correct |
214 ms |
228628 KB |
Output is correct |
51 |
Correct |
174 ms |
240684 KB |
Output is correct |
52 |
Correct |
207 ms |
251932 KB |
Output is correct |
53 |
Correct |
197 ms |
255480 KB |
Output is correct |
54 |
Correct |
139 ms |
259132 KB |
Output is correct |
55 |
Correct |
95 ms |
261496 KB |
Output is correct |
56 |
Correct |
181 ms |
269164 KB |
Output is correct |
57 |
Correct |
119 ms |
271776 KB |
Output is correct |
58 |
Correct |
107 ms |
275180 KB |
Output is correct |
59 |
Correct |
117 ms |
280604 KB |
Output is correct |