QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#664624 | #2788. Horses | Pioneer | 17 | 115ms | 48488kb | C++20 | 3.3kb | 2024-10-21 21:28:42 | 2024-10-21 21:28:42 |
Judging History
answer
#include "horses.h"
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll inf=1e9;
const int mod=1e9+7;
const int MAX=5e5+10;
int x[MAX];
int y[MAX];
struct segtree{
pair<int,bool> t[4*MAX];
pair<int,bool> mrg(pair<int,bool> a,pair<int,bool> b){
pair<int,bool> res={a.first*1ll*b.first%mod,(a.second|b.second)};
if(a.first*1ll*b.first>=mod){
res.second=1;
}
return res;
}
void build(int v,int tl,int tr){
if(tl==tr){
t[v]={x[tl],0};
return;
}
int tm=(tl+tr)/2;
build(2*v,tl,tm);
build(2*v+1,tm+1,tr);
t[v]=mrg(t[2*v],t[2*v+1]);
}
void update(int v,int tl,int tr,int pos,int x){
if(tl==tr){
t[v]={x,0};
return;
}
int tm=(tl+tr)/2;
if(pos<=tm)update(2*v,tl,tm,pos,x);
else update(2*v+1,tm+1,tr,pos,x);
t[v]=mrg(t[2*v],t[2*v+1]);
}
pair<int,bool> get(int v,int tl,int tr,int l,int r){
if(l>r||tl>r||l>tr)return {1,0};
if(l<=tl&&tr<=r)return t[v];
int tm=(tl+tr)/2;
return mrg(get(2*v,tl,tm,l,r),get(2*v+1,tm+1,tr,l,r));
}
}tx;
struct segtreeMx{
pair<int,int> t[MAX];
pair<int,int> mrg(pair<int,int> a,pair<int,int> b){
if(a.first>=b.first)return a;
else return b;
}
void build(int v,int tl,int tr){
if(tl==tr){
t[v]={y[tl],tl};
return;
}
int tm=(tl+tr)/2;
build(2*v,tl,tm);
build(2*v+1,tm+1,tr);
t[v]=mrg(t[2*v],t[2*v+1]);
}
void update(int v,int tl,int tr,int pos,int x){
if(tl==tr){
t[v]={x,tl};
return;
}
int tm=(tl+tr)/2;
if(pos<=tm)update(2*v,tl,tm,pos,x);
else update(2*v+1,tm+1,tr,pos,x);
t[v]=mrg(t[2*v],t[2*v+1]);
}
pair<int,int> get(int v,int tl,int tr,int l,int r){
if(l>r||tl>r||l>tr)return {0,0};
if(l<=tl&&tr<=r)return t[v];
int tm=(tl+tr)/2;
return mrg(get(2*v,tl,tm,l,r),get(2*v+1,tm+1,tr,l,r));
}
}ty;
int n;
set<int> st;
int get(int pos){
int ans=1;
for(int i=1;i<=pos;i++)ans=ans*1ll*x[i]%mod;
return ans*1ll*y[pos]%mod;
return tx.get(1,1,n,1,pos).first*1ll*y[pos]%mod;
}
int get(){
{
int pos=n;
int per=x[n]*1ll*y[n]%mod;
bool bf=0;
if(x[n]*1ll*y[n]>=mod)bf=1;
for(int i=n-1;i>=max(1,n-1000);i--){
if(!bf&&y[i]>=per){
pos=i;
per=y[i];
bf=0;
}
if(per*1ll*x[i]>=mod){
bf=1;
}
per=per*1ll*x[i]%mod;
}
return get(pos);
}
st.insert(1);
vector<int> vec;
int pos=ty.get(1,1,n,*st.rbegin(),n).second;
vec.push_back(*st.rbegin());
st.erase(--st.end());
while(!st.empty()){
int pos1=ty.get(1,1,n,*st.rbegin(),vec.back()-1).second;
vec.push_back(*st.rbegin());
st.erase(--st.end());
pair<int,bool> bf=tx.get(1,1,n,pos1+1,pos);
if(bf.second||bf.first*1ll*y[pos]>=mod)break;
if(bf.first*y[pos]<=y[pos1])pos=pos1;
}
for(int x:vec)st.insert(x);
return get(pos);
}
int init(int N, int X[], int Y[]) {
n=N;
for(int i=0;i<N;i++){
y[i+1]=Y[i];
x[i+1]=X[i];
if(X[i]!=1){
st.insert(i+1);
}
}
tx.build(1,1,n);
ty.build(1,1,n);
return get();
}
int updateX(int pos, int val) {
return 0;
return 0;
pos++;
if(x[pos]!=1)st.erase(pos);
x[pos]=val;
tx.update(1,1,n,pos,val);
if(x[pos]!=1)st.insert(pos);
return get();
}
int updateY(int pos, int val) {
return 0;
pos++;
y[pos]=val;
ty.update(1,1,n,pos,val);
return get();
}
詳細信息
Subtask #1:
score: 17
Accepted
Test #1:
score: 17
Accepted
time: 1ms
memory: 10020kb
input:
1 2 3 0
output:
6
result:
ok single line: '6'
Test #2:
score: 17
Accepted
time: 1ms
memory: 9944kb
input:
10 2 1 1 5 2 1 1 10 5 1 3 5 7 9 4 1 4 10 10 9 0
output:
10000
result:
ok single line: '10000'
Test #3:
score: 17
Accepted
time: 1ms
memory: 10128kb
input:
10 10 10 10 1 1 1 1 1 1 1 2 3 4 2 7 6 5 4 3 2 0
output:
7000
result:
ok single line: '7000'
Test #4:
score: 17
Accepted
time: 1ms
memory: 10020kb
input:
10 9 1 1 1 1 1 1 1 1 2 4 1 1 1 1 1 1 1 1 2 0
output:
36
result:
ok single line: '36'
Test #5:
score: 17
Accepted
time: 1ms
memory: 7900kb
input:
10 1 1 1 1 1 1 1 1 1 1 1 2 3 4 5 6 7 8 9 10 0
output:
10
result:
ok single line: '10'
Test #6:
score: 17
Accepted
time: 1ms
memory: 9936kb
input:
10 1 1 1 1 1 1 1 1 1 1 10 9 8 7 6 5 4 3 2 1 0
output:
10
result:
ok single line: '10'
Test #7:
score: 17
Accepted
time: 1ms
memory: 10064kb
input:
10 10 10 10 1 1 1 1 1 1 1 10 10 2 3 4 5 6 7 8 9 0
output:
9000
result:
ok single line: '9000'
Test #8:
score: 17
Accepted
time: 0ms
memory: 10092kb
input:
10 10 10 10 1 1 1 1 1 1 1 10 10 9 8 7 6 5 4 3 2 0
output:
9000
result:
ok single line: '9000'
Test #9:
score: 17
Accepted
time: 1ms
memory: 10020kb
input:
10 1 1 1 1 2 2 1 1 1 1 8 8 8 8 1 1 2 2 2 2 0
output:
8
result:
ok single line: '8'
Test #10:
score: 17
Accepted
time: 1ms
memory: 10016kb
input:
10 1 1 1 1 1 1 1 1 1 1 1 2 3 4 5 9 8 7 6 1 0
output:
9
result:
ok single line: '9'
Test #11:
score: 17
Accepted
time: 1ms
memory: 10016kb
input:
2 2 5 9 7 0
output:
70
result:
ok single line: '70'
Test #12:
score: 17
Accepted
time: 1ms
memory: 9952kb
input:
1 1 1 0
output:
1
result:
ok single line: '1'
Test #13:
score: 17
Accepted
time: 1ms
memory: 9940kb
input:
7 7 1 1 6 2 3 2 7 6 5 4 3 7 1 0
output:
1764
result:
ok single line: '1764'
Test #14:
score: 17
Accepted
time: 1ms
memory: 10128kb
input:
1 10 10 0
output:
100
result:
ok single line: '100'
Test #15:
score: 17
Accepted
time: 1ms
memory: 9940kb
input:
2 1 4 7 2 0
output:
8
result:
ok single line: '8'
Test #16:
score: 17
Accepted
time: 0ms
memory: 10012kb
input:
10 1 10 1 10 1 1 10 1 1 1 7 3 10 10 4 10 1 4 5 10 0
output:
10000
result:
ok single line: '10000'
Test #17:
score: 17
Accepted
time: 1ms
memory: 10008kb
input:
6 1 1 1 1 1 1 1 1 1 1 1 1 0
output:
1
result:
ok single line: '1'
Test #18:
score: 17
Accepted
time: 1ms
memory: 10008kb
input:
4 1 2 4 8 8 4 2 1 0
output:
64
result:
ok single line: '64'
Test #19:
score: 17
Accepted
time: 1ms
memory: 10008kb
input:
6 1 2 2 3 1 1 7 1 1 2 1 1 0
output:
24
result:
ok single line: '24'
Test #20:
score: 17
Accepted
time: 1ms
memory: 10012kb
input:
10 2 1 1 5 2 1 1 10 5 1 3 5 7 9 4 1 4 10 7 9 0
output:
9000
result:
ok single line: '9000'
Subtask #2:
score: 0
Wrong Answer
Dependency #1:
100%
Accepted
Test #21:
score: 0
Wrong Answer
time: 1ms
memory: 10020kb
input:
10 10 10 10 10 10 10 1 1 1 1 1 1 1 1 9 5 4 7 3 2 5 1 5 1 2 5 123456789 1 5 1 1 8 987654321 1 9 777777777
output:
7000000 0 0 0 0 0
result:
wrong answer 2nd lines differ - expected: '900000', found: '0'
Subtask #3:
score: 0
Wrong Answer
Test #33:
score: 0
Wrong Answer
time: 115ms
memory: 48488kb
input:
500000 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2...
output:
967631222 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
result:
wrong answer 2nd lines differ - expected: '967631222', found: '0'
Subtask #4:
score: 0
Skipped
Dependency #2:
0%
Subtask #5:
score: 0
Skipped
Dependency #1:
100%
Accepted
Dependency #2:
0%