Submission #464684

#TimeUsernameProblemLanguageResultExecution timeMemory
464684Blobo2_Blobo2Strah (COCI18_strah)C++14
22 / 110
1099 ms31568 KiB
/* Editor: Abdelrahman Hossam Nickname: Blobo2_Blobo2 IOI next year isA :) */ /*#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3") //#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.2,popcnt,abm,mmx,avx2,tune=native") #pragma GCC optimize("-ffast-math") #pragma GCC optimize("-funroll-loops") #pragma GCC optimize("-funroll-all-loops,-fpeel-loops,-funswitch-loops")*/ #include<bits/stdc++.h> using namespace std; //#define int long long #define endl "\n" #define all(v) v.begin(),v.end() #define gen(arr,n,nxt) generate(arr,arr+n,nxt) #define Blobo2_el_7akim_elly_3ayz_yro7_IOI_w_3ayz_yakol_jilaty ios_base::sync_with_stdio(false);cin.tie(0); const int mo=1e9+7,INF=1e18; int nxt(){int x;cin>>x;return x;} signed main(){ Blobo2_el_7akim_elly_3ayz_yro7_IOI_w_3ayz_yakol_jilaty int n=nxt(),m=nxt(); int grid[n][m]; for(int i=0;i<n;i++){ string s; cin>>s; for(int j=0;j<m;j++) grid[i][j] = (s[j] == '#'); } int pre[n][m]; for(int i=0;i<m;i++) pre[0][i] = grid[0][i]; for(int i=1;i<n;i++) for(int j=0;j<m;j++) pre[i][j]=grid[i][j]+pre[i-1][j]; for(int i=0;i<n;i++) for(int j=1;j<m;j++) pre[i][j]+=pre[i][j-1]; long long cnt=0; for(int topX=0;topX<n;topX++){ for(int topY=0;topY<m;topY++){ if(grid[topX][topY] == 1)continue; for(int bottomX=topX;bottomX<n;bottomX++){ for(int bottomY=topY;bottomY<m;bottomY++){ if(grid[bottomX][bottomY] == 1)continue; int res=pre[bottomX][bottomY]; if(topX>0) res-=pre[topX-1][bottomY]; if(topY>0) res-=pre[bottomX][topY-1]; if(topX>0&&topY>0) res+=pre[topX-1][topY-1]; cnt+=(res?0ll:(abs(topX-bottomX)+1)*(abs(topY-bottomY)+1)); } } } } cout<<cnt<<endl; return 0; }

Compilation message (stderr)

strah.cpp:19:24: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+18' to '2147483647' [-Woverflow]
   19 | const int mo=1e9+7,INF=1e18;
      |                        ^~~~
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...