# |
제출 시각 |
아이디 |
문제 |
언어 |
결과 |
실행 시간 |
메모리 |
1030286 |
2024-07-22T02:13:52 Z |
pcc |
말 (IOI15_horses) |
C++17 |
|
466 ms |
57684 KB |
#include "horses.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<ll,ll>
#define fs first
#define sc second
const ll mod = 1e9+7;
const ll mxn = 5e5+10;
int N;
int arr[mxn],brr[mxn];
set<int> st;
struct SEG{
#define ls now*2+1
#define rs now*2+2
#define mid ((l+r)>>1)
int mx[mxn*4];
ll seg[mxn*4];
void build(int now,int l,int r){
if(l == r){
seg[now] = arr[l];
mx[now] = brr[l];
return;
}
build(ls,l,mid);
build(rs,mid+1,r);
mx[now] = max(mx[ls],mx[rs]);
seg[now] = seg[ls]*seg[rs];
if(seg[now]>=mod)seg[now] = mod+seg[now]%mod;
return;
}
void modify(int now,int l,int r,int p){
if(l == r){
seg[now] = arr[l];
mx[now] = brr[l];
return;
}
if(mid>=p)modify(ls,l,mid,p);
else modify(rs,mid+1,r,p);
mx[now] = max(mx[ls],mx[rs]);
seg[now] = seg[ls]*seg[rs];
if(seg[now]>=mod)seg[now] = mod+seg[now]%mod;
}
ll getsum(int now,int l,int r,int s,int e){
if(l>=s&&e>=r)return seg[now];
if(mid>=e)return getsum(ls,l,mid,s,e);
else if(mid<s)return getsum(rs,mid+1,r,s,e);
else{
auto re = getsum(ls,l,mid,s,e)*getsum(rs,mid+1,r,s,e);
if(re>=mod)return mod+re%mod;
else return re;
}
}
ll getmax(int now,int l,int r,int s,int e){
if(l>=s&&e>=r)return mx[now];
if(mid>=e)return getmax(ls,l,mid,s,e);
else if(mid<s)return getmax(rs,mid+1,r,s,e);
else return max(getmax(ls,l,mid,s,e),getmax(rs,mid+1,r,s,e));
}
#undef ls
#undef rs
#undef mid
};
SEG seg;
bool cmp(int a,int b){
if(a>b)return seg.getmax(0,0,N-1,a,N-1)*seg.getsum(0,0,N-1,b+1,a)<seg.getmax(0,0,N-1,b,N-1);
else return seg.getmax(0,0,N-1,a,N-1)<seg.getmax(0,0,N-1,b,N-1)*seg.getsum(0,0,N-1,a+1,b);
}
ll getans(){
st.insert(0);
vector<int> need;
ll pref = 1;
for(auto it = st.rbegin();it != st.rend()&&pref<mod;it++){
need.push_back(*it);
pref *= arr[*it];
}
sort(need.begin(),need.end());
int tar = need[0];
for(int i = 1;i<need.size();i++){
if(cmp(tar,need[i]))tar = need[i];
}
return seg.getmax(0,0,N-1,tar,N-1)*seg.getsum(0,0,N-1,0,tar)%mod;
}
int init(int NN, int X[], int Y[]) {
N = NN;
for(int i = 0;i<N;i++){
arr[i] = X[i];
if(arr[i] != 1)st.insert(i);
brr[i] = Y[i];
}
seg.build(0,0,N-1);
//cerr<<"INIT! "<<seg.getmax(0,0,N-1,0,N-1)<<endl;
return getans();
}
int updateX(int pos, int val) {
arr[pos] = val;
if(arr[pos] != 1)st.insert(pos);
else if(arr[pos] == 1&&st.find(pos) != st.end())st.erase(pos);
seg.modify(0,0,N-1,pos);
return getans();
}
int updateY(int pos, int val) {
brr[pos] = val;
seg.modify(0,0,N-1,pos);
return getans();
}
Compilation message
horses.cpp: In function 'long long int getans()':
horses.cpp:85:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
85 | for(int i = 1;i<need.size();i++){
| ~^~~~~~~~~~~~
horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:100:15: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
100 | return getans();
| ~~~~~~^~
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:108:15: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
108 | return getans();
| ~~~~~~^~
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:114:15: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
114 | return getans();
| ~~~~~~^~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
456 KB |
Output is correct |
5 |
Correct |
0 ms |
604 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
452 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
21 |
Correct |
0 ms |
344 KB |
Output is correct |
22 |
Correct |
0 ms |
348 KB |
Output is correct |
23 |
Correct |
1 ms |
348 KB |
Output is correct |
24 |
Correct |
1 ms |
460 KB |
Output is correct |
25 |
Correct |
1 ms |
348 KB |
Output is correct |
26 |
Correct |
1 ms |
464 KB |
Output is correct |
27 |
Correct |
3 ms |
548 KB |
Output is correct |
28 |
Correct |
2 ms |
348 KB |
Output is correct |
29 |
Correct |
1 ms |
348 KB |
Output is correct |
30 |
Correct |
1 ms |
468 KB |
Output is correct |
31 |
Correct |
2 ms |
344 KB |
Output is correct |
32 |
Correct |
3 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
449 ms |
48724 KB |
Output is correct |
2 |
Correct |
245 ms |
57684 KB |
Output is correct |
3 |
Correct |
235 ms |
48724 KB |
Output is correct |
4 |
Correct |
298 ms |
52616 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
600 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
452 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
344 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
0 ms |
344 KB |
Output is correct |
21 |
Correct |
0 ms |
348 KB |
Output is correct |
22 |
Correct |
0 ms |
348 KB |
Output is correct |
23 |
Correct |
1 ms |
348 KB |
Output is correct |
24 |
Correct |
1 ms |
348 KB |
Output is correct |
25 |
Correct |
1 ms |
604 KB |
Output is correct |
26 |
Correct |
1 ms |
348 KB |
Output is correct |
27 |
Correct |
3 ms |
348 KB |
Output is correct |
28 |
Correct |
1 ms |
348 KB |
Output is correct |
29 |
Correct |
1 ms |
348 KB |
Output is correct |
30 |
Correct |
1 ms |
348 KB |
Output is correct |
31 |
Correct |
2 ms |
348 KB |
Output is correct |
32 |
Correct |
3 ms |
348 KB |
Output is correct |
33 |
Correct |
40 ms |
24660 KB |
Output is correct |
34 |
Correct |
33 ms |
24640 KB |
Output is correct |
35 |
Correct |
156 ms |
54856 KB |
Output is correct |
36 |
Correct |
150 ms |
54780 KB |
Output is correct |
37 |
Correct |
66 ms |
22868 KB |
Output is correct |
38 |
Correct |
95 ms |
35684 KB |
Output is correct |
39 |
Correct |
24 ms |
22620 KB |
Output is correct |
40 |
Correct |
132 ms |
49952 KB |
Output is correct |
41 |
Correct |
56 ms |
22620 KB |
Output is correct |
42 |
Correct |
69 ms |
22880 KB |
Output is correct |
43 |
Correct |
125 ms |
50256 KB |
Output is correct |
44 |
Correct |
127 ms |
50260 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
456 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
344 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
344 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
452 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
21 |
Correct |
0 ms |
348 KB |
Output is correct |
22 |
Correct |
0 ms |
348 KB |
Output is correct |
23 |
Correct |
1 ms |
348 KB |
Output is correct |
24 |
Correct |
1 ms |
348 KB |
Output is correct |
25 |
Correct |
1 ms |
348 KB |
Output is correct |
26 |
Correct |
1 ms |
348 KB |
Output is correct |
27 |
Correct |
3 ms |
348 KB |
Output is correct |
28 |
Correct |
1 ms |
348 KB |
Output is correct |
29 |
Correct |
1 ms |
344 KB |
Output is correct |
30 |
Correct |
1 ms |
348 KB |
Output is correct |
31 |
Correct |
2 ms |
348 KB |
Output is correct |
32 |
Correct |
3 ms |
348 KB |
Output is correct |
33 |
Correct |
466 ms |
48848 KB |
Output is correct |
34 |
Correct |
243 ms |
57500 KB |
Output is correct |
35 |
Correct |
276 ms |
48820 KB |
Output is correct |
36 |
Correct |
274 ms |
52592 KB |
Output is correct |
37 |
Correct |
33 ms |
24656 KB |
Output is correct |
38 |
Correct |
33 ms |
24660 KB |
Output is correct |
39 |
Correct |
152 ms |
54992 KB |
Output is correct |
40 |
Correct |
148 ms |
54844 KB |
Output is correct |
41 |
Correct |
60 ms |
22868 KB |
Output is correct |
42 |
Correct |
79 ms |
35668 KB |
Output is correct |
43 |
Correct |
25 ms |
22608 KB |
Output is correct |
44 |
Correct |
128 ms |
50040 KB |
Output is correct |
45 |
Correct |
60 ms |
22620 KB |
Output is correct |
46 |
Correct |
61 ms |
22748 KB |
Output is correct |
47 |
Correct |
132 ms |
50252 KB |
Output is correct |
48 |
Correct |
127 ms |
50312 KB |
Output is correct |
49 |
Correct |
124 ms |
27728 KB |
Output is correct |
50 |
Correct |
93 ms |
27752 KB |
Output is correct |
51 |
Correct |
262 ms |
56752 KB |
Output is correct |
52 |
Correct |
206 ms |
56400 KB |
Output is correct |
53 |
Correct |
434 ms |
25856 KB |
Output is correct |
54 |
Correct |
218 ms |
39428 KB |
Output is correct |
55 |
Correct |
87 ms |
23744 KB |
Output is correct |
56 |
Correct |
197 ms |
51792 KB |
Output is correct |
57 |
Correct |
416 ms |
24148 KB |
Output is correct |
58 |
Correct |
461 ms |
24744 KB |
Output is correct |
59 |
Correct |
142 ms |
50372 KB |
Output is correct |