Submission #1128490

#TimeUsernameProblemLanguageResultExecution timeMemory
1128490erasyl123Bomb (IZhO17_bomb)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
#define int long long
#define boost ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
const int N = 2505;
const int inf = 1e9;
const int mod=1e9+7;
struct edge{
    int pos,val,t;
};
int dp[N][N];
string c[N];
int dp1[N][N];
int n,m;
vector<pair<int,int> >v[N];
int ch(int mid){
    int ok=0;
    for(int k=0;j<v[mid].size();k++){
            int cnt=0;
            int i=v[mid].first;
            int j=v[mid].second;
            for(int y=1;y+i-1<=n;y++){
                for(int x=1;x+j-1<=m;x++){
                    int x1=x+(j-1);
                    int y1=y+(i-1);
                    int cnt=dp[y1][x1]-dp[y1][x - 1]-dp[y - 1][x1]+dp[y - 1][x - 1];
                    if(cnt==i*j){
                        dp1[y][x]++;
                        dp1[y1+1][x]--;
                        dp1[y][x1+1]--;
                        dp1[y1+1][x1+1]++;
                    }
                }
            }
            int cnt1=0;
            for(int y=1;y<=n;y++){
                for(int x=1;x<=m;x++){
                    dp1[y][x]+=dp1[y-1][x]+dp1[y][x-1]-dp1[y-1][x-1];
                    if(dp1[y][x]>0){
                        cnt1++;
                    }
                }
            }
            if(cnt1==dp[n][m]){
                ans=max(ans,i*j);
                ok=1;
            }
            for(int i=1;i<=n;i++){
                for(int j=1;j<=m;j++){
                    dp1[i][j]=0;
                }
            }
            if(ok==1){
                break;
            }
    }
    return ok;
}
signed main(){
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
     boost 
    cin>>n>>m;
    for(int i=1;i<=n;i++){
            cin>>c[i];
            for(int j=0;j<m;j++){
            int x=0;
            if(c[i][j]=='1'){
                x=1;
            }
            dp[i][j+1]=dp[i-1][j+1]+dp[i][j]-dp[i-1][j]+x;
            }
    }
    for(int i=1;i<=2500;i++){
        for(int j=1;j<i;j++){
            if(i%j==0){
                v[i].push_back({j,i/j});
            }
        }
    }
    int ans=0;
    int l=1,r=m*n;
    while(l+1<r){
        int mid=(l+r)/2;
        if(ch(mid)==1){
            l=mid;
        }else{
            r=mid;
        }
    }
    if(ch(r)==1){
        l=r;
    }
    if(ch(l)==0){
        cout<<0;
        return 0;
    }
    cout<<l;
}

Compilation message (stderr)

bomb.cpp: In function 'long long int ch(long long int)':
bomb.cpp:18:30: error: call to non-'constexpr' function 'std::vector<_Tp, _Alloc>::size_type std::vector<_Tp, _Alloc>::size() const [with _Tp = std::pair<long long int, long long int>; _Alloc = std::allocator<std::pair<long long int, long long int> >; std::vector<_Tp, _Alloc>::size_type = long unsigned int]'
   18 |     for(int k=0;j<v[mid].size();k++){
      |                   ~~~~~~~~~~~^~
In file included from /usr/include/c++/11/vector:67,
                 from /usr/include/c++/11/functional:62,
                 from /usr/include/c++/11/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/11/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65,
                 from bomb.cpp:1:
/usr/include/c++/11/bits/stl_vector.h:918:7: note: 'std::vector<_Tp, _Alloc>::size_type std::vector<_Tp, _Alloc>::size() const [with _Tp = std::pair<long long int, long long int>; _Alloc = std::allocator<std::pair<long long int, long long int> >; std::vector<_Tp, _Alloc>::size_type = long unsigned int]' declared here
  918 |       size() const _GLIBCXX_NOEXCEPT
      |       ^~~~
bomb.cpp:18:30: error: call to non-'constexpr' function 'std::vector<_Tp, _Alloc>::size_type std::vector<_Tp, _Alloc>::size() const [with _Tp = std::pair<long long int, long long int>; _Alloc = std::allocator<std::pair<long long int, long long int> >; std::vector<_Tp, _Alloc>::size_type = long unsigned int]'
   18 |     for(int k=0;j<v[mid].size();k++){
      |                   ~~~~~~~~~~~^~
In file included from /usr/include/c++/11/vector:67,
                 from /usr/include/c++/11/functional:62,
                 from /usr/include/c++/11/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/11/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65,
                 from bomb.cpp:1:
/usr/include/c++/11/bits/stl_vector.h:918:7: note: 'std::vector<_Tp, _Alloc>::size_type std::vector<_Tp, _Alloc>::size() const [with _Tp = std::pair<long long int, long long int>; _Alloc = std::allocator<std::pair<long long int, long long int> >; std::vector<_Tp, _Alloc>::size_type = long unsigned int]' declared here
  918 |       size() const _GLIBCXX_NOEXCEPT
      |       ^~~~
bomb.cpp:18:30: error: call to non-'constexpr' function 'std::vector<_Tp, _Alloc>::size_type std::vector<_Tp, _Alloc>::size() const [with _Tp = std::pair<long long int, long long int>; _Alloc = std::allocator<std::pair<long long int, long long int> >; std::vector<_Tp, _Alloc>::size_type = long unsigned int]'
   18 |     for(int k=0;j<v[mid].size();k++){
      |                   ~~~~~~~~~~~^~
In file included from /usr/include/c++/11/vector:67,
                 from /usr/include/c++/11/functional:62,
                 from /usr/include/c++/11/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/11/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65,
                 from bomb.cpp:1:
/usr/include/c++/11/bits/stl_vector.h:918:7: note: 'std::vector<_Tp, _Alloc>::size_type std::vector<_Tp, _Alloc>::size() const [with _Tp = std::pair<long long int, long long int>; _Alloc = std::allocator<std::pair<long long int, long long int> >; std::vector<_Tp, _Alloc>::size_type = long unsigned int]' declared here
  918 |       size() const _GLIBCXX_NOEXCEPT
      |       ^~~~
bomb.cpp:18:30: error: call to non-'constexpr' function 'std::vector<_Tp, _Alloc>::size_type std::vector<_Tp, _Alloc>::size() const [with _Tp = std::pair<long long int, long long int>; _Alloc = std::allocator<std::pair<long long int, long long int> >; std::vector<_Tp, _Alloc>::size_type = long unsigned int]'
   18 |     for(int k=0;j<v[mid].size();k++){
      |                   ~~~~~~~~~~~^~
In file included from /usr/include/c++/11/vector:67,
                 from /usr/include/c++/11/functional:62,
                 from /usr/include/c++/11/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/11/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65,
                 from bomb.cpp:1:
/usr/include/c++/11/bits/stl_vector.h:918:7: note: 'std::vector<_Tp, _Alloc>::size_type std::vector<_Tp, _Alloc>::size() const [with _Tp = std::pair<long long int, long long int>; _Alloc = std::allocator<std::pair<long long int, long long int> >; std::vector<_Tp, _Alloc>::size_type = long unsigned int]' declared here
  918 |       size() const _GLIBCXX_NOEXCEPT
      |       ^~~~
bomb.cpp:18:30: error: call to non-'constexpr' function 'std::vector<_Tp, _Alloc>::size_type std::vector<_Tp, _Alloc>::size() const [with _Tp = std::pair<long long int, long long int>; _Alloc = std::allocator<std::pair<long long int, long long int> >; std::vector<_Tp, _Alloc>::size_type = long unsigned int]'
   18 |     for(int k=0;j<v[mid].size();k++){
      |                   ~~~~~~~~~~~^~
In file included from /usr/include/c++/11/vector:67,
                 from /usr/include/c++/11/functional:62,
                 from /usr/include/c++/11/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/11/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65,
                 from bomb.cpp:1:
/usr/include/c++/11/bits/stl_vector.h:918:7: note: 'std::vector<_Tp, _Alloc>::size_type std::vector<_Tp, _Alloc>::size() const [with _Tp = std::pair<long long int, long long int>; _Alloc = std::allocator<std::pair<long long int, long long int> >; std::vector<_Tp, _Alloc>::size_type = long unsigned int]' declared here
  918 |       size() const _GLIBCXX_NOEXCEPT
      |       ^~~~
bomb.cpp:18:30: error: call to non-'constexpr' function 'std::vector<_Tp, _Alloc>::size_type std::vector<_Tp, _Alloc>::size() const [with _Tp = std::pair<long long int, long long int>; _Alloc = std::allocator<std::pair<long long int, long long int> >; std::vector<_Tp, _Alloc>::size_type = long unsigned int]'
   18 |     for(int k=0;j<v[mid].size();k++){
      |                   ~~~~~~~~~~~^~
In file included from /usr/include/c++/11/vector:67,
                 from /usr/include/c++/11/functional:62,
                 from /usr/include/c++/11/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/11/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65,
                 from bomb.cpp:1:
/usr/include/c++/11/bits/stl_vector.h:918:7: note: 'std::vector<_Tp, _Alloc>::size_type std::vector<_Tp, _Alloc>::size() const [with _Tp = std::pair<long long int, long long int>; _Alloc = std::allocator<std::pair<long long int, long long int> >; std::vector<_Tp, _Alloc>::size_type = long unsigned int]' declared here
  918 |       size() const _GLIBCXX_NOEXCEPT
      |       ^~~~
bomb.cpp:18:30: error: call to non-'constexpr' function 'std::vector<_Tp, _Alloc>::size_type std::vector<_Tp, _Alloc>::size() const [with _Tp = std::pair<long long int, long long int>; _Alloc = std::allocator<std::pair<long long int, long long int> >; std::vector<_Tp, _Alloc>::size_type = long unsigned int]'
   18 |     for(int k=0;j<v[mid].size();k++){
      |                   ~~~~~~~~~~~^~
In file included from /usr/include/c++/11/vector:67,
                 from /usr/include/c++/11/functional:62,
                 from /usr/include/c++/11/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/11/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65,
                 from bomb.cpp:1:
/usr/include/c++/11/bits/stl_vector.h:918:7: note: 'std::vector<_Tp, _Alloc>::size_type std::vector<_Tp, _Alloc>::size() const [with _Tp = std::pair<long long int, long long int>; _Alloc = std::allocator<std::pair<long long int, long long int> >; std::vector<_Tp, _Alloc>::size_type = long unsigned int]' declared here
  918 |       size() const _GLIBCXX_NOEXCEPT
      |       ^~~~
bomb.cpp:18:30: error: call to non-'constexpr' function 'std::vector<_Tp, _Alloc>::size_type std::vector<_Tp, _Alloc>::size() const [with _Tp = std::pair<long long int, long long int>; _Alloc = std::allocator<std::pair<long long int, long long int> >; std::vector<_Tp, _Alloc>::size_type = long unsigned int]'
   18 |     for(int k=0;j<v[mid].size();k++){
      |                   ~~~~~~~~~~~^~
In file included from /usr/include/c++/11/vector:67,
                 from /usr/include/c++/11/functional:62,
                 from /usr/include/c++/11/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/11/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65,
                 from bomb.cpp:1:
/usr/include/c++/11/bits/stl_vector.h:918:7: note: 'std::vector<_Tp, _Alloc>::size_type std::vector<_Tp, _Alloc>::size() const [with _Tp = std::pair<long long int, long long int>; _Alloc = std::allocator<std::pair<long long int, long long int> >; std::vector<_Tp, _Alloc>::size_type = long unsigned int]' declared here
  918 |       size() const _GLIBCXX_NOEXCEPT
      |       ^~~~
bomb.cpp:18:30: error: call to non-'constexpr' function 'std::vector<_Tp, _Alloc>::size_type std::vector<_Tp, _Alloc>::size() const [with _Tp = std::pair<long long int, long long int>; _Alloc = std::allocator<std::pair<long long int, long long int> >; std::vector<_Tp, _Alloc>::size_type = long unsigned int]'
   18 |     for(int k=0;j<v[mid].size();k++){
      |                   ~~~~~~~~~~~^~
In file included from /usr/include/c++/11/vector:67,
                 from /usr/include/c++/11/functional:62,
                 from /usr/include/c++/11/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/11/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65,
                 from bomb.cpp:1:
/usr/include/c++/11/bits/stl_vector.h:918:7: note: 'std::vector<_Tp, _Alloc>::size_type std::vector<_Tp, _Alloc>::size() const [with _Tp = std::pair<long long int, long long int>; _Alloc = std::allocator<std::pair<long long int, long long int> >; std::vector<_Tp, _Alloc>::size_type = long unsigned int]' declared here
  918 |       size() const _GLIBCXX_NOEXCEPT
      |       ^~~~
bomb.cpp:18:17: error: 'j' was not declared in this scope
   18 |     for(int k=0;j<v[mid].size();k++){
      |                 ^
bomb.cpp:20:26: error: 'class std::vector<std::pair<long long int, long long int> >' has no member named 'first'
   20 |             int i=v[mid].first;
      |                          ^~~~~
bomb.cpp:21:26: error: 'class std::vector<std::pair<long long int, long long int> >' has no member named 'second'
   21 |             int j=v[mid].second;
      |                          ^~~~~~
bomb.cpp:45:17: error: 'ans' was not declared in this scope; did you mean 'abs'?
   45 |                 ans=max(ans,i*j);
      |                 ^~~
      |                 abs