제출 #416920

#제출 시각아이디문제언어결과실행 시간메모리
416920Theo830Rectangles (IOI19_rect)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; typedef short ll; const ll INF = 1e9+7; ll MOD = 998244353; typedef pair<ll,ll> ii; #define iii pair<ll,ii> #define f(i,a,b) for(ll i = a;i < b;i++) #define pb push_back #define vll vector<ll> #define F first #define S second #define all(x) (x).begin(), (x).end() ///I hope I will get uprating and don't make mistakes ///I will never stop programming ///sqrt(-1) Love C++ ///Please don't hack me ///@TheofanisOrfanou Theo830 ///Think different approaches (bs,dp,greedy,graphs,shortest paths,mst) ///Stay Calm ///Look for special cases ///Beware of overflow and array bounds ///Think the problem backwards ///Training mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); uniform_int_distribution<ll> distr; ll rnd(ll a, ll b){return distr(rng)%(b-a+1)+a;} #include "rect.h" /* long long count_rectangles(std::vector<std::vector<int> > a); int main() { int n, m; cin>>n>>m; vector<vector<int>> a(n, vector<int>(m)); for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { cin>>a[i][j]; } } long long result = count_rectangles(a); printf("%lld\n", result); return 0; } */ bool ok1[700][700][700]; bool ok2[700][700][700]; ll pre1[700][700][701]; long long count_rectangles(vector<vector<int> > a){ long long ans = 0; ll n = a.size(); ll m = a[0].size(); f(i,1,n-1){ f(j,1,m-1){ ll Maxi = a[i][j]; ok1[i][j][j] = min(a[i][j-1],a[i][j+1]) > Maxi; f(k,j+1,m-1){ Maxi = max(Maxi,a[i][k]); ok1[i][j][k] = min(a[i][j-1],a[i][k+1]) > Maxi; } } } f(i,1,m-1){ f(j,1,n-1){ ll maxi = a[j][i]; ok2[i][j][j] = min(a[j-1][i],a[j+1][i]) > maxi; f(k,j+1,n-1){ maxi = max(maxi,a[k][i]); ok2[i][j][k] = min(a[j-1][i],a[k+1][i]) > maxi; } } } f(j,1,m-1){ f(jj,j,m-1){ pre1[j][jj][0] = 0; f(k,0,n){ pre1[j][jj][k+1] = pre1[j][jj][k] + ok1[k][j][jj]; } } } f(i,1,n-1){ f(ii,i,n-1){ f(j,1,m-1){ ll posa = 0; f(jj,j,m-1){ posa += ok2[jj][i][ii]; bool ok = (pre1[j][jj][ii+1] - pre1[j][jj][i]) == (ii - i + 1); bool ok2 = (posa == (jj - j + 1)); if(!ok2){ break; } ans += ok & ok2; } } } } return ans; } /* 6 5 4 8 7 5 6 7 4 10 3 5 9 7 20 14 2 9 14 7 3 6 5 7 5 2 7 4 5 13 5 6 */

컴파일 시 표준 에러 (stderr) 메시지

rect.cpp:4:19: warning: overflow in conversion from 'double' to 'll' {aka 'short int'} changes value from '1.000000007e+9' to '32767' [-Woverflow]
    4 | const ll INF = 1e9+7;
      |                ~~~^~
rect.cpp:5:10: warning: overflow in conversion from 'int' to 'll' {aka 'short int'} changes value from '998244353' to '1' [-Woverflow]
    5 | ll MOD = 998244353;
      |          ^~~~~~~~~
rect.cpp: In function 'long long int count_rectangles(std::vector<std::vector<int> >)':
rect.cpp:58:40: error: no matching function for call to 'max(ll&, __gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type&)'
   58 |                 Maxi = max(Maxi,a[i][k]);
      |                                        ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from rect.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:254:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  254 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
rect.cpp:58:40: note:   deduced conflicting types for parameter 'const _Tp' ('short int' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'})
   58 |                 Maxi = max(Maxi,a[i][k]);
      |                                        ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from rect.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:300:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
rect.cpp:58:40: note:   deduced conflicting types for parameter 'const _Tp' ('short int' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'})
   58 |                 Maxi = max(Maxi,a[i][k]);
      |                                        ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from rect.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3480:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3480 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3480:5: note:   template argument deduction/substitution failed:
rect.cpp:58:40: note:   mismatched types 'std::initializer_list<_Tp>' and 'short int'
   58 |                 Maxi = max(Maxi,a[i][k]);
      |                                        ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from rect.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3486:5: note:   template argument deduction/substitution failed:
rect.cpp:58:40: note:   mismatched types 'std::initializer_list<_Tp>' and 'short int'
   58 |                 Maxi = max(Maxi,a[i][k]);
      |                                        ^
rect.cpp:68:40: error: no matching function for call to 'max(ll&, __gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type&)'
   68 |                 maxi = max(maxi,a[k][i]);
      |                                        ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from rect.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:254:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  254 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
rect.cpp:68:40: note:   deduced conflicting types for parameter 'const _Tp' ('short int' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'})
   68 |                 maxi = max(maxi,a[k][i]);
      |                                        ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from rect.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:300:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
rect.cpp:68:40: note:   deduced conflicting types for parameter 'const _Tp' ('short int' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'})
   68 |                 maxi = max(maxi,a[k][i]);
      |                                        ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from rect.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3480:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3480 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3480:5: note:   template argument deduction/substitution failed:
rect.cpp:68:40: note:   mismatched types 'std::initializer_list<_Tp>' and 'short int'
   68 |                 maxi = max(maxi,a[k][i]);
      |                                        ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from rect.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3486:5: note:   template argument deduction/substitution failed:
rect.cpp:68:40: note:   mismatched types 'std::initializer_list<_Tp>' and 'short int'
   68 |                 maxi = max(maxi,a[k][i]);
      |                                        ^