답안 #464684

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
464684 2021-08-13T16:46:49 Z Blobo2_Blobo2 Strah (COCI18_strah) C++14
22 / 110
1000 ms 31568 KB
/*
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

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;
      |                        ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1094 ms 972 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1057 ms 972 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1079 ms 972 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1082 ms 8440 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1097 ms 19520 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1094 ms 12492 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1099 ms 2252 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1082 ms 31568 KB Time limit exceeded
2 Halted 0 ms 0 KB -