Submission #1102333

#TimeUsernameProblemLanguageResultExecution timeMemory
1102333modwweMosaic (IOI24_mosaic)C++17
100 / 100
121 ms32388 KiB
#pragma GCC optimize("Ofast,unroll-loops") #include<bits/stdc++.h> #define int2 long long //#define ll long long #define down cout<<'\n'; #define debug cout<<" cucuucucuuu",down #define NHP ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0); #define modwwe int t;cin>>t; while(t--) #define bit(i,j) (i>>j&1) #define sobit(a) __builtin_popcountll(a) #define task "test" #define fin(x) freopen(x".inp","r",stdin) #define fou(x) freopen(x".ans","w",stdout) #define pb push_back #define checktime cerr << (double)clock() / CLOCKS_PER_SEC * 1000 << " ms"; using namespace std; #define getchar_unlocked getchar inline int scan() { char c = getchar_unlocked(); int x = 0; while(c<'0'||c>'9') { c=getchar_unlocked(); } while(c>='0'&&c<='9') { x=(x<<1)+(x<<3)+c-'0'; c=getchar_unlocked(); } return x; } void phongbeo(); const int inf=1e9; const int mod2=1e9+9; const int mod1=998244353; struct icd { long double a; int b; }; struct ib { int a; int b; }; struct ic { int a,b,c; }; struct id { int a,b,c,d; }; struct ie { int a,b,c,d,e; }; int n,m,s1,s2,s4,s3,sf,k,s5,s6,mx,s7,s8,s9,mx2,res,dem2=0,dem=0,s33,dem3,dem4,l,r,mid,l2,r2,center; int i,s10,s12; int kk; int el=29; int2 a[200001]; int2 b[200001]; int dp1[4][200001]; int dp2[200001][4]; int2 dista[200001]; int2 distb[200001]; vector<int2> v; int2 get(int l,int r) { if(l<=2)return dp1[l][r]; if(r<=2) return dp2[l][r]; int2 s=dp2[l][2]+dp1[2][r]-dp2[2][2]; l-=2; r-=2; if(r>l) { return distb[l]+dista[r]-a[1]*min(r,l)-dista[r-l]+s; } else { return dista[r]+distb[l]-a[1]*min(l,r)-distb[l-r]+s; } } vector<long long> mosaic(vector<int> X, vector<int> Y,vector<int> T, vector<int> B,vector<int> L, vector<int> R) { n=X.size(); for(int i=1; i<=n; i++) a[i]=X[i-1]; for(int i=1; i<=n; i++) b[i]=Y[i-1]; for(int i=1; i<=n; i++) dp1[1][i]=a[i]; dp1[2][1]=b[2]; dp1[3][1]=b[3]; for(int i=2; i<=3; i++) for(int j=2; j<=n; j++) dp1[i][j]=1-max(dp1[i-1][j],dp1[i][j-1]); for(int i=1; i<=n; i++) dp2[i][1]=b[i]; dp2[1][2]=a[2]; dp2[1][3]=a[3]; for(int i=2; i<=n; i++) for(int j=2; j<=3; j++) dp2[i][j]=1-max(dp2[i-1][j],dp2[i][j-1]); for(int i=3; i<=n; i++) { a[i-2]=dp1[3][i], b[i-2]=dp2[i][3]; } for(int i=1; i<=n; i++) for(int j=1; j<=3; j++) dp2[i][j]+=dp2[i-1][j]+dp2[i][j-1]-dp2[i-1][j-1]; for(int i=1; i<=3; i++) for(int j=1; j<=n; j++) dp1[i][j]+=dp1[i-1][j]+dp1[i][j-1]-dp1[i-1][j-1]; n-=2; for(int i=1; i<=n; i++) { a[i]+=a[i-1],dista[i]=dista[i-1]+a[i], b[i]+=b[i-1],distb[i]=distb[i-1]+b[i]; } /** for(int i=1;i<=n;i++) cout<<a[i]<<" "; down for(int i=1;i<=n;i++) cout<<b[i]<<" ";*/ m=T.size(); for(int i=1; i<=m; i++) { l=T[i-1]+1; r=L[i-1]+1; l2=B[i-1]+1; r2=R[i-1]+1; v.pb(get(l2,r2)+get(l-1,r-1)-get(l2,r-1)-get(l-1,r2)); } return v; } /* main() { freopen("test.inp","r",stdin); freopen("test.ans","w",stdout); cin>>n; vector<int>a1,a2,a3,a4,a5,a6; for(int i=1; i<=n; i++) cin>>l,a1.pb(l); for(int i=1; i<=n; i++) cin>>l,a2.pb(l); cin>>m; for(int i=1; i<=m; i++) { cin>>l>>r>>l2>>r2; a3.pb(l); a5.pb(r); a4.pb(l2); a6.pb(r2); } vector<int2> vv=mosaic(a1,a2,a3,a4,a5,a6); for(auto x:vv) cout<<x,down }*/
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...