# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
830392 | 2023-08-19T05:36:31 Z | Supersonic | 말 (IOI15_horses) | C++14 | 549 ms | 73304 KB |
#include "horses.h" #include <bits/stdc++.h> using namespace std; typedef unsigned long long ll; ll h[500001]; ll x[500001]; ll y[500001]; bool subtask3=1; int n; set<int, greater<int>> g1; ll tree[1048577]; ll ytree[1048577]; unordered_map<ll,int> ry; void modify(int k, int x) { k += n; tree[k] = x; for (k /= 2; k >= 1; k /= 2) { tree[k] = tree[2*k]*tree[2*k+1]; tree[k]%=((ll)1e9+7); } } ll prod(ll a, ll b) { a += n; b += n; ll s = 1; while (a <= b) { if (a%2 == 1) {s *= tree[a++];s%=((ll)1e9+7);} if (b%2 == 0) {s *= tree[b--];s%=((ll)1e9+7);} a /= 2; b /= 2; } return s; } void ymodify(int k, int x) { if(k>2*n)exit(1); k += n; ytree[k] = x; for (k /= 2; k >= 1; k /= 2) { ytree[k] = max(ytree[2*k],ytree[2*k+1]); ytree[k]%=((ll)1e9+7); } } ll rmax(ll a,ll b){ if(b>2*n)exit(1); a += n; b += n; ll s = 0; while (a <= b) { if (a%2 == 1) {s = max(s,ytree[a++]);} if (b%2 == 0) {s = max(s,ytree[b--]);} a /= 2; b /= 2; } return s; } int init(int N, int X[], int Y[]) { n=N; if(n<=1000)subtask3=0; for(int i=0;i<n;i++){ x[i]=X[i]; if(x[i]<2)subtask3=0; modify(i,x[i]); y[i]=Y[i]; ry[y[i]]=i; ymodify(i,y[i]); if(x[i]>1)g1.insert(i); } //if(subtask3)exit(1); //cout<<rmax(2,2)<<endl;; if(!subtask3){ ll mp=0;ll c=1; for(int i=1;i<n;i++){ c*=x[i]; if(c>y[mp]||y[i]>y[mp]||c*y[i]>y[mp]){mp=i;c=1;} } return (prod(0,mp)*y[mp])%((ll)1e9+7); } else{ ll mp=n-33;ll c=1; for(int i=n-32;i<n;i++){ c*=x[i]; if(c>y[mp]||y[i]>y[mp]||c*y[i]>y[mp]){mp=i;c=1;} } return (prod(0,mp)*y[mp])%((ll)1e9+7); } } int sc=500; int updateX(int pos, int val) { if(val==1&&g1.count(pos))g1.erase(pos); if(val>1)g1.insert(pos); x[pos]=val; sc--; if(g1.empty())exit(1); //if(sc==0){for(auto i:g1)if(x[i]==1)exit(1);for(int i=0;i<n;i++)if(x[i]==1&&g1.count(i))exit(1);sc=500;} modify(pos,val); ll c=x[0];ll mp=0; vector<int> vv;int cn=34; for(auto i:g1){vv.push_back(i);cn--;if(cn==0)break;} reverse(vv.begin(),vv.end()); for(int vvi=0;vvi<vv.size();vvi++){ int vi=vv[vvi]; int vni=n-1;if(vvi!=vv.size()-1)vni=vv[vvi+1]-1; int i=ry[rmax(vi,vni)]; if(i>=n)exit(1); c*=x[vi]; if(c>y[mp]||y[i]>y[mp]||c*y[i]>y[mp]){mp=i;c=1;} } return (prod(0,mp)*y[mp])%((ll)1e9+7); } int updateY(int pos, int val) { y[pos]=val; ymodify(pos,val); ry[y[pos]]=pos; ll c=x[0];ll mp=0; vector<int> vv;int cn=34; for(auto i:g1){vv.push_back(i);cn--;if(cn==0)break;} reverse(vv.begin(),vv.end()); for(int vvi=0;vvi<vv.size();vvi++){ int vi=vv[vvi]; int vni=n-1;if(vvi!=vv.size()-1)vni=vv[vvi+1]-1; int i=ry[rmax(vi,vni)]; if(i>=n)exit(1); c*=x[vi]; if(c>y[mp]||y[i]>y[mp]||c*y[i]>y[mp]){mp=i;c=1;} } return (prod(0,mp)*y[mp])%((ll)1e9+7); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
7 | Correct | 0 ms | 212 KB | Output is correct |
8 | Correct | 0 ms | 212 KB | Output is correct |
9 | Correct | 1 ms | 212 KB | Output is correct |
10 | Correct | 0 ms | 212 KB | Output is correct |
11 | Correct | 0 ms | 212 KB | Output is correct |
12 | Correct | 0 ms | 212 KB | Output is correct |
13 | Correct | 0 ms | 212 KB | Output is correct |
14 | Correct | 0 ms | 212 KB | Output is correct |
15 | Correct | 0 ms | 212 KB | Output is correct |
16 | Correct | 0 ms | 212 KB | Output is correct |
17 | Correct | 0 ms | 212 KB | Output is correct |
18 | Correct | 0 ms | 340 KB | Output is correct |
19 | Correct | 0 ms | 212 KB | Output is correct |
20 | Correct | 0 ms | 212 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
7 | Correct | 0 ms | 212 KB | Output is correct |
8 | Correct | 0 ms | 212 KB | Output is correct |
9 | Correct | 0 ms | 212 KB | Output is correct |
10 | Correct | 0 ms | 212 KB | Output is correct |
11 | Correct | 0 ms | 212 KB | Output is correct |
12 | Correct | 0 ms | 212 KB | Output is correct |
13 | Correct | 0 ms | 212 KB | Output is correct |
14 | Correct | 0 ms | 212 KB | Output is correct |
15 | Correct | 0 ms | 212 KB | Output is correct |
16 | Correct | 0 ms | 212 KB | Output is correct |
17 | Correct | 0 ms | 212 KB | Output is correct |
18 | Correct | 0 ms | 212 KB | Output is correct |
19 | Correct | 0 ms | 212 KB | Output is correct |
20 | Correct | 0 ms | 212 KB | Output is correct |
21 | Correct | 0 ms | 212 KB | Output is correct |
22 | Correct | 0 ms | 212 KB | Output is correct |
23 | Correct | 2 ms | 468 KB | Output is correct |
24 | Correct | 1 ms | 468 KB | Output is correct |
25 | Incorrect | 1 ms | 340 KB | Output isn't correct |
26 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 297 ms | 56720 KB | Output is correct |
2 | Correct | 383 ms | 54340 KB | Output is correct |
3 | Correct | 344 ms | 54408 KB | Output is correct |
4 | Correct | 549 ms | 73304 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 212 KB | Output is correct |
8 | Correct | 0 ms | 212 KB | Output is correct |
9 | Correct | 0 ms | 212 KB | Output is correct |
10 | Correct | 0 ms | 212 KB | Output is correct |
11 | Correct | 0 ms | 212 KB | Output is correct |
12 | Correct | 0 ms | 212 KB | Output is correct |
13 | Correct | 0 ms | 212 KB | Output is correct |
14 | Correct | 0 ms | 212 KB | Output is correct |
15 | Correct | 0 ms | 212 KB | Output is correct |
16 | Correct | 0 ms | 212 KB | Output is correct |
17 | Correct | 0 ms | 212 KB | Output is correct |
18 | Correct | 0 ms | 212 KB | Output is correct |
19 | Correct | 0 ms | 212 KB | Output is correct |
20 | Correct | 0 ms | 212 KB | Output is correct |
21 | Correct | 0 ms | 212 KB | Output is correct |
22 | Correct | 0 ms | 212 KB | Output is correct |
23 | Correct | 2 ms | 340 KB | Output is correct |
24 | Correct | 1 ms | 340 KB | Output is correct |
25 | Incorrect | 2 ms | 384 KB | Output isn't correct |
26 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
7 | Correct | 0 ms | 212 KB | Output is correct |
8 | Correct | 0 ms | 212 KB | Output is correct |
9 | Correct | 0 ms | 212 KB | Output is correct |
10 | Correct | 0 ms | 212 KB | Output is correct |
11 | Correct | 0 ms | 212 KB | Output is correct |
12 | Correct | 0 ms | 212 KB | Output is correct |
13 | Correct | 0 ms | 212 KB | Output is correct |
14 | Correct | 0 ms | 212 KB | Output is correct |
15 | Correct | 0 ms | 212 KB | Output is correct |
16 | Correct | 0 ms | 212 KB | Output is correct |
17 | Correct | 0 ms | 212 KB | Output is correct |
18 | Correct | 0 ms | 212 KB | Output is correct |
19 | Correct | 0 ms | 212 KB | Output is correct |
20 | Correct | 0 ms | 212 KB | Output is correct |
21 | Correct | 0 ms | 212 KB | Output is correct |
22 | Correct | 0 ms | 212 KB | Output is correct |
23 | Correct | 2 ms | 340 KB | Output is correct |
24 | Correct | 1 ms | 468 KB | Output is correct |
25 | Incorrect | 1 ms | 340 KB | Output isn't correct |
26 | Halted | 0 ms | 0 KB | - |