# |
제출 시각 |
아이디 |
문제 |
언어 |
결과 |
실행 시간 |
메모리 |
596432 |
2022-07-14T18:19:49 Z |
neki |
말 (IOI15_horses) |
C++14 |
|
327 ms |
55988 KB |
#include <bits/stdc++.h>
#define ll long long
#define vc vector
using namespace std;
const ll mn=500100, mod=1000000007;
ll x[mn], y[mn], n;
ll tpro[2 * mn];
ll tmax[2 * mn];
set<ll> act;
ll my[mn];
void updpro(ll pos, ll val){
for (tpro[pos += mn]=val; pos > 1; pos >>= 1) tpro[pos>>1]=(tpro[pos] * tpro[pos^1])%mod;
}
void updmax(ll pos, ll val){
for (tmax[pos += mn]=val; pos > 1; pos >>= 1) tmax[pos>>1]=max(tmax[pos], tmax[pos^1]);
}
ll getpro(ll l, ll r){
ll ret=1;
for(l+=mn, r+=mn;l<r;l>>=1, r>>=1){
if(l&1) ret*=tpro[l++];
if(r&1) ret*=tpro[--r];
ret%=mod;
}
return ret;
}
ll getmax(ll l, ll r){
ll ret=0;
for(l+=mn, r+=mn;l<r;l>>=1, r>>=1){
if(l&1) ret=max(ret, tmax[l++]);
if(r&1) ret=max(ret, tmax[--r]);
}
return ret;
}
void getmy(ll pos){
ll l=pos, r;
auto pr=act.upper_bound(pos);
if(pr==act.end()) r=n;
else r=(*pr);
//cout << l <<" " << r << " " << getmax(l, r)<<endl;
my[pos]=getmax(l, r);
}
ll getyear(ll pos){
//cout << pos << " " << getpro(0, pos+1) <<" " << y[pos]<< endl;
assert(act.count(pos));
return (getpro(0, pos+1) * my[pos])%mod;
}
ll getans(){
vc<ll> preglej;
auto poi = act.end();
for(ll cur=1;;){
if(poi==act.begin()) break;
--poi;
cur*=x[*poi];
//cout << *poi << " " << cur << endl;
preglej.push_back(*poi);
if(cur>INT_MAX) break;
}
//cout << preglej.size() <<endl;
reverse(preglej.begin(), preglej.end());
vc<ll> px(preglej.size(), 1);
px[0]=x[preglej[0]];
for(ll i=1;i<preglej.size();++i) px[i]=px[i-1] * x[preglej[i]];
for(ll i=0;i<preglej.size();++i) px[i]*=my[preglej[i]];
//for(ll i=0;i<preglej.size();++i) cout << px[i] <<" "; cout << endl;
ll best=max_element(px.begin(), px.end())-px.begin();
return getyear(preglej[best]);
}
int updateX(int pos, int val){
if(x[pos]>1 or pos==0) act.erase(pos);
x[pos]=val;updpro(pos, val);
if(x[pos]>1 or pos==0) act.insert(pos);
auto zau = act.upper_bound(pos); --zau;
getmy(*zau);
if(zau!=act.begin()){--zau; getmy(*zau);}
return getans();
}
int updateY(int pos, int val){
y[pos]=val;updmax(pos, val);
auto poi=act.upper_bound(pos);--poi;
getmy(*poi);
return getans();
}
int init(int N, int X[], int Y[]){
n=N;for(ll i=0;i<n;++i) x[i]=X[i], y[i]=Y[i];
for(ll i=0;i<n;++i) updpro(i, X[i]), updmax(i, Y[i]);
for(ll i=0;i<n;++i) if(x[i]>1 or i==0) act.insert(i);
for(ll i=0;i<n;++i) if(x[i]>1 or i==0) getmy(i);
return getans();
}
Compilation message
horses.cpp: In function 'long long int getans()':
horses.cpp:71:17: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
71 | for(ll i=1;i<preglej.size();++i) px[i]=px[i-1] * x[preglej[i]];
| ~^~~~~~~~~~~~~~~
horses.cpp:74:17: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
74 | for(ll i=0;i<preglej.size();++i) px[i]*=my[preglej[i]];
| ~^~~~~~~~~~~~~~~
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:91:18: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
91 | return getans();
| ~~~~~~^~
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:98:18: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
98 | return getans();
| ~~~~~~^~
horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:106:18: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
106 | return getans();
| ~~~~~~^~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
0 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
0 ms |
340 KB |
Output is correct |
8 |
Correct |
0 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
0 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
0 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
0 ms |
340 KB |
Output is correct |
15 |
Correct |
0 ms |
340 KB |
Output is correct |
16 |
Correct |
0 ms |
340 KB |
Output is correct |
17 |
Correct |
0 ms |
340 KB |
Output is correct |
18 |
Correct |
0 ms |
340 KB |
Output is correct |
19 |
Correct |
0 ms |
340 KB |
Output is correct |
20 |
Correct |
0 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
420 KB |
Output is correct |
5 |
Correct |
0 ms |
340 KB |
Output is correct |
6 |
Correct |
0 ms |
340 KB |
Output is correct |
7 |
Correct |
0 ms |
340 KB |
Output is correct |
8 |
Correct |
0 ms |
340 KB |
Output is correct |
9 |
Correct |
0 ms |
340 KB |
Output is correct |
10 |
Correct |
0 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
0 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
0 ms |
340 KB |
Output is correct |
15 |
Correct |
0 ms |
340 KB |
Output is correct |
16 |
Correct |
0 ms |
340 KB |
Output is correct |
17 |
Correct |
0 ms |
340 KB |
Output is correct |
18 |
Correct |
0 ms |
340 KB |
Output is correct |
19 |
Correct |
0 ms |
340 KB |
Output is correct |
20 |
Correct |
1 ms |
340 KB |
Output is correct |
21 |
Correct |
0 ms |
340 KB |
Output is correct |
22 |
Correct |
0 ms |
340 KB |
Output is correct |
23 |
Incorrect |
1 ms |
468 KB |
Output isn't correct |
24 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
327 ms |
55988 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
0 ms |
340 KB |
Output is correct |
6 |
Correct |
0 ms |
340 KB |
Output is correct |
7 |
Correct |
0 ms |
340 KB |
Output is correct |
8 |
Correct |
0 ms |
340 KB |
Output is correct |
9 |
Correct |
0 ms |
340 KB |
Output is correct |
10 |
Correct |
0 ms |
340 KB |
Output is correct |
11 |
Correct |
0 ms |
340 KB |
Output is correct |
12 |
Correct |
0 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
0 ms |
340 KB |
Output is correct |
15 |
Correct |
0 ms |
340 KB |
Output is correct |
16 |
Correct |
0 ms |
340 KB |
Output is correct |
17 |
Correct |
0 ms |
340 KB |
Output is correct |
18 |
Correct |
0 ms |
340 KB |
Output is correct |
19 |
Correct |
0 ms |
340 KB |
Output is correct |
20 |
Correct |
0 ms |
340 KB |
Output is correct |
21 |
Correct |
0 ms |
340 KB |
Output is correct |
22 |
Correct |
0 ms |
340 KB |
Output is correct |
23 |
Incorrect |
1 ms |
468 KB |
Output isn't correct |
24 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
0 ms |
340 KB |
Output is correct |
6 |
Correct |
0 ms |
340 KB |
Output is correct |
7 |
Correct |
0 ms |
340 KB |
Output is correct |
8 |
Correct |
0 ms |
340 KB |
Output is correct |
9 |
Correct |
0 ms |
340 KB |
Output is correct |
10 |
Correct |
0 ms |
340 KB |
Output is correct |
11 |
Correct |
0 ms |
340 KB |
Output is correct |
12 |
Correct |
0 ms |
340 KB |
Output is correct |
13 |
Correct |
0 ms |
340 KB |
Output is correct |
14 |
Correct |
0 ms |
340 KB |
Output is correct |
15 |
Correct |
0 ms |
340 KB |
Output is correct |
16 |
Correct |
0 ms |
340 KB |
Output is correct |
17 |
Correct |
0 ms |
340 KB |
Output is correct |
18 |
Correct |
1 ms |
340 KB |
Output is correct |
19 |
Correct |
0 ms |
340 KB |
Output is correct |
20 |
Correct |
0 ms |
340 KB |
Output is correct |
21 |
Correct |
0 ms |
340 KB |
Output is correct |
22 |
Correct |
0 ms |
340 KB |
Output is correct |
23 |
Incorrect |
1 ms |
468 KB |
Output isn't correct |
24 |
Halted |
0 ms |
0 KB |
- |