Submission #253937

#TimeUsernameProblemLanguageResultExecution timeMemory
253937khangalRectangles (IOI19_rect)C++14
Compilation error
0 ms0 KiB
#include<bits/stdc++.h>
using namespace std;
typedef int ll;
typedef pair<ll,ll> pl;
typedef vector<ll> vl;
#define po pop_back
#define pb push_back
#define mk make_pair
#define lw lower_bound
#define up upper_bound
#define ff first
#define ss second
#define boost ios_base::sync_with_stdio(); cin.tie(0); cout.tie(0);
#define MOD 1000000007
#define MAX 1e18
#define MIN -1e18
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define per(i,a,b) for(ll i=b;i>=a;i--)
#define con continue
#define freopen freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define PI 3.14159265358979323846264338327950288419716939937510582097494459230781640628
// typedef tree<ll , null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
// template< typename T>
// using indexed_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll n,m,ans,mid,mn,mx,cnt,T,sum,h1,h2,e[1234567],b[1234567],c[1234567],d[1<<20],k,i,j,l,r,h,a[1234567],w,x,y,z;
bool used[1234567];
vector<int> v[1234567],vec,vv1,vv2;
string s1,s;
int sz[1234567],par[1234567];
ll dx[4]={-1,1,0,0},dy[4]={0,0,-1,1},c1[123][123];
void add(ll x , ll val){
    for(x++; x < 2500; x += x & -x) tr[x] += val;
}
ll qry(ll x){
    ll res = 0;
    for(x++; x; x -= x & -x) res += tr[x];
    return res;
}
vector<ll> vv[2][2501];
vector<pl> vp[2];
ll aa[2][maxn][maxn], lst[2][maxn][maxn], cnt[2][maxn][maxn];
ll count_rectangles(vector<vector<int> > vec){
    ll n=vec.size();
    ll m=vec[0].size();
    for(ll i = 0; i < n; i++) vv[0][i].pb(0);
    for(ll i = 0; i < m; i++) vv[1][i].pb(0);
    ll res = 0;
    for(ll i = 0; i < n - 1; i++)
    for(ll j = 0; j < m - 1; j++){
        aa[0][i][j] = aa[1][j][i] = vec[i][j];
        aa[0][i][j + 1] = vec[i][j + 1];
        aa[1][j][i + 1] = vec[i + 1][j];
        for(ll t = 0; t < 2; t++){
            bool ok = 0;
            vp[t].clear();
            while(!vv[t][i].empty()){
                ll c = vv[t][i].back();
                if(c < j && !ok){
                    if(lst[t][c][j + 1] != i - 1) cnt[t][c][j + 1] = 0;
                    cnt[t][c][j + 1]++ , lst[t][c][j + 1] = i;
                    vp[t].pb({j - c, cnt[t][c][j + 1]});
                    if(t) swap(vp[t].back().ff, vp[t].back().ss);
                }
                ok = aa[t][i][c] == aa[t][i][j + 1];
                if(aa[t][i][c] <= aa[t][i][j + 1]) vv[t][i].po();
                else break;
            }
            vv[t][i].pb(j + 1);
            swap(i , j);
            sort(vp[t].begin(), vp[t].end());
        }
        ll it = 0;
        for(auto u : vp[0]){
            for(; it < vp[1].size() && u.ff <= vp[1][it].ff; it++) add(vp[1][it].ss, 1);
            res += qry(u.ss);
        }
        for(ll jt = 0; jt < it; jt++) add(vp[1][jt].ss, -1);
    }
    return res;
}

Compilation message (stderr)

rect.cpp: In function 'void add(ll, ll)':
rect.cpp:32:37: error: 'tr' was not declared in this scope
     for(x++; x < 2500; x += x & -x) tr[x] += val;
                                     ^~
rect.cpp:32:37: note: suggested alternative: 'r'
     for(x++; x < 2500; x += x & -x) tr[x] += val;
                                     ^~
                                     r
rect.cpp: In function 'll qry(ll)':
rect.cpp:36:37: error: 'tr' was not declared in this scope
     for(x++; x; x -= x & -x) res += tr[x];
                                     ^~
rect.cpp:36:37: note: suggested alternative: 'r'
     for(x++; x; x -= x & -x) res += tr[x];
                                     ^~
                                     r
rect.cpp: At global scope:
rect.cpp:41:10: error: 'maxn' was not declared in this scope
 ll aa[2][maxn][maxn], lst[2][maxn][maxn], cnt[2][maxn][maxn];
          ^~~~
rect.cpp:41:10: note: suggested alternative: 'mx'
 ll aa[2][maxn][maxn], lst[2][maxn][maxn], cnt[2][maxn][maxn];
          ^~~~
          mx
rect.cpp:41:16: error: 'maxn' was not declared in this scope
 ll aa[2][maxn][maxn], lst[2][maxn][maxn], cnt[2][maxn][maxn];
                ^~~~
rect.cpp:41:16: note: suggested alternative: 'mx'
 ll aa[2][maxn][maxn], lst[2][maxn][maxn], cnt[2][maxn][maxn];
                ^~~~
                mx
rect.cpp:41:30: error: 'maxn' was not declared in this scope
 ll aa[2][maxn][maxn], lst[2][maxn][maxn], cnt[2][maxn][maxn];
                              ^~~~
rect.cpp:41:30: note: suggested alternative: 'mx'
 ll aa[2][maxn][maxn], lst[2][maxn][maxn], cnt[2][maxn][maxn];
                              ^~~~
                              mx
rect.cpp:41:36: error: 'maxn' was not declared in this scope
 ll aa[2][maxn][maxn], lst[2][maxn][maxn], cnt[2][maxn][maxn];
                                    ^~~~
rect.cpp:41:36: note: suggested alternative: 'mx'
 ll aa[2][maxn][maxn], lst[2][maxn][maxn], cnt[2][maxn][maxn];
                                    ^~~~
                                    mx
rect.cpp:41:50: error: 'maxn' was not declared in this scope
 ll aa[2][maxn][maxn], lst[2][maxn][maxn], cnt[2][maxn][maxn];
                                                  ^~~~
rect.cpp:41:50: note: suggested alternative: 'mx'
 ll aa[2][maxn][maxn], lst[2][maxn][maxn], cnt[2][maxn][maxn];
                                                  ^~~~
                                                  mx
rect.cpp:41:56: error: 'maxn' was not declared in this scope
 ll aa[2][maxn][maxn], lst[2][maxn][maxn], cnt[2][maxn][maxn];
                                                        ^~~~
rect.cpp:41:56: note: suggested alternative: 'mx'
 ll aa[2][maxn][maxn], lst[2][maxn][maxn], cnt[2][maxn][maxn];
                                                        ^~~~
                                                        mx
rect.cpp: In function 'll count_rectangles(std::vector<std::vector<int> >)':
rect.cpp:50:9: error: 'aa' was not declared in this scope
         aa[0][i][j] = aa[1][j][i] = vec[i][j];
         ^~
rect.cpp:50:9: note: suggested alternative: 'a'
         aa[0][i][j] = aa[1][j][i] = vec[i][j];
         ^~
         a
rect.cpp:59:24: error: 'lst' was not declared in this scope
                     if(lst[t][c][j + 1] != i - 1) cnt[t][c][j + 1] = 0;
                        ^~~
rect.cpp:59:56: error: invalid types 'll {aka int}[ll {aka int}]' for array subscript
                     if(lst[t][c][j + 1] != i - 1) cnt[t][c][j + 1] = 0;
                                                        ^
rect.cpp:60:26: error: invalid types 'll {aka int}[ll {aka int}]' for array subscript
                     cnt[t][c][j + 1]++ , lst[t][c][j + 1] = i;
                          ^
rect.cpp:60:42: error: 'lst' was not declared in this scope
                     cnt[t][c][j + 1]++ , lst[t][c][j + 1] = i;
                                          ^~~
rect.cpp:61:43: error: invalid types 'll {aka int}[ll {aka int}]' for array subscript
                     vp[t].pb({j - c, cnt[t][c][j + 1]});
                                           ^
rect.cpp:61:55: error: no matching function for call to 'std::vector<std::pair<int, int> >::push_back(<brace-enclosed initializer list>)'
                     vp[t].pb({j - c, cnt[t][c][j + 1]});
                                                       ^
In file included from /usr/include/c++/7/vector:64:0,
                 from /usr/include/c++/7/queue:61,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:86,
                 from rect.cpp:1:
/usr/include/c++/7/bits/stl_vector.h:939:7: note: candidate: void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; std::vector<_Tp, _Alloc>::value_type = std::pair<int, int>]
       push_back(const value_type& __x)
       ^~~~~~~~~
/usr/include/c++/7/bits/stl_vector.h:939:7: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type& {aka const std::pair<int, int>&}'
/usr/include/c++/7/bits/stl_vector.h:953:7: note: candidate: void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; std::vector<_Tp, _Alloc>::value_type = std::pair<int, int>]
       push_back(value_type&& __x)
       ^~~~~~~~~
/usr/include/c++/7/bits/stl_vector.h:953:7: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::vector<std::pair<int, int> >::value_type&& {aka std::pair<int, int>&&}'
rect.cpp:74:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for(; it < vp[1].size() && u.ff <= vp[1][it].ff; it++) add(vp[1][it].ss, 1);
                   ~~~^~~~~~~~~~~~~~