QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#303997#7785. Three RectanglescanineCompile Error//C++233.2kb2024-01-13 11:04:492024-01-13 11:04:49

Judging History

你现在查看的是最新测评结果

  • [2024-01-13 11:04:49]
  • 评测
  • [2024-01-13 11:04:49]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;

int main() {
  cin.tie(0)->sync_with_stdio(0); cin.exceptions(cin.failbit);
  int t; cin>>t;
  const ll m = 1e9+7;
  while (t--) {
    ll h,w; cin>>h>>w;
    using Pt = pair<ll,ll>;
    array<Pt,3> dim;
    for (auto& [a,b]: dim) cin>>b>>a;
    
    ll out=0;
    for (int i=0; i<3; i++) {
      if (dim[i].first==w && dim[i].second==h) {
        out=1;
        for (int j=0; j<3; j++) out=out*((h-dim[j].second+1)*(w-dim[j].first+1) %m) %m;
        break;
      }

      for (int j=0; j<3; j++) {
        if (j==i) continue;

        int k = 3-i-j;
        Pt bl, tr;
        if (dim[i].first<w && dim[j].second<h
          && ((dim[i].second==h && dim[j].first>=w-dim[i].first)
            || (dim[j].first==w && dim[i].second>=h-dim[i].second))) {
          //top right corner uncovered
          bl={dim[i].first+1, dim[j].second+1};
          tr={w,h};

        } else if (dim[i].second<h && dim[j].first<w
          && (((dim[i].first==w && dim[j].second>=h-dim[i].second)
            || (dim[j].second==h && dim[i].first>=w-dim[j].first)))) {
          //bottom left corner uncovered

          bl={1,1};
          tr={w-dim[j].first, h-dim[i].second};
        } else if ((dim[i].first<w && dim[j].second<h
          && ((dim[i].second==h && dim[j].first<w-dim[i].first
            && dim[k].second==h && dim[k].first>=w-dim[i].first && k>j)

          || (dim[j].first==w && dim[i].second<h-dim[i].second
            && dim[k].first==w && dim[k].second>=h-dim[j].second && k>i)))
          
          || (dim[i].second<h && dim[j].first<w
            && (((dim[i].first==w && dim[j].second<h-dim[i].second
              && dim[k].first==w && dim[k].second>=h-dim[i].first && k>j)

            || (dim[j].second==h && dim[i].first<w-dim[j].first
              && dim[k].second==h && dim[k].first>=w-dim[j].first && k>i))))) {
          
          out=(out+1)%m;
          continue;
        } else if (dim[i].first==w && dim[j].first==w) {
          bl = {1, dim[j].second+1};
          tr = {w, h-dim[i].second};
        } else if (dim[i].second==h && dim[j].second==h) {
          bl = {dim[i].first+1, 1};
          tr = {w-dim[j].first, h};
        } else {
          continue;
        }
        
        if (bl.first>tr.first || bl.second>tr.second) {
          out = (out+((h-dim[k].second+1)*(w-dim[k].first+1) %m) + (m-((k<i) + (k<j))))%m;
          continue;
        }

        if (dim[k].second < tr.second-bl.second+1 || dim[k].first < tr.first-bl.first+1) {
          continue;
        }
        
        Pt obl = bl;
        bl = {tr.first-dim[k].first+1, tr.second};
        tr = {obl.first, obl.second+dim[k].second-1};
        
        ll w1 = w-dim[k].first+1, h1=dim[k].second;
        bl.first=clamp(bl.first, 1ll,w1);
        tr.first=clamp(tr.first, 1ll,w1);
        bl.second=clamp(bl.second, h1,h);
        tr.second=clamp(tr.second, h1,h);
        
        out=(out + (tr.second-bl.second+1)*(tr.first-bl.first+1) %m)%m;
        
        if (bl.first==1 && tr.second==h && k<i) out=(out+m-1)%m;
        if (tr.first==w1 && bl.second==h1 && k<j) out=(out+m-1)%m;
      }
    }
    
    cout<<out<<"\n";
  }
}

Details

answer.code: In function ‘int main()’:
answer.code:82:23: error: no matching function for call to ‘clamp(long int&, long long int, ll&)’
   82 |         bl.first=clamp(bl.first, 1ll,w1);
      |                  ~~~~~^~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/string:52,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from answer.code:1:
/usr/include/c++/11/bits/stl_algo.h:3656:5: note: candidate: ‘template<class _Tp> constexpr const _Tp& std::clamp(const _Tp&, const _Tp&, const _Tp&)’
 3656 |     clamp(const _Tp& __val, const _Tp& __lo, const _Tp& __hi)
      |     ^~~~~
/usr/include/c++/11/bits/stl_algo.h:3656:5: note:   template argument deduction/substitution failed:
answer.code:82:23: note:   deduced conflicting types for parameter ‘const _Tp’ (‘long int’ and ‘long long int’)
   82 |         bl.first=clamp(bl.first, 1ll,w1);
      |                  ~~~~~^~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/string:52,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from answer.code:1:
/usr/include/c++/11/bits/stl_algo.h:3674:5: note: candidate: ‘template<class _Tp, class _Compare> constexpr const _Tp& std::clamp(const _Tp&, const _Tp&, const _Tp&, _Compare)’
 3674 |     clamp(const _Tp& __val, const _Tp& __lo, const _Tp& __hi, _Compare __comp)
      |     ^~~~~
/usr/include/c++/11/bits/stl_algo.h:3674:5: note:   template argument deduction/substitution failed:
answer.code:82:23: note:   deduced conflicting types for parameter ‘const _Tp’ (‘long int’ and ‘long long int’)
   82 |         bl.first=clamp(bl.first, 1ll,w1);
      |                  ~~~~~^~~~~~~~~~~~~~~~~~
answer.code:83:23: error: no matching function for call to ‘clamp(long int&, long long int, ll&)’
   83 |         tr.first=clamp(tr.first, 1ll,w1);
      |                  ~~~~~^~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/string:52,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from answer.code:1:
/usr/include/c++/11/bits/stl_algo.h:3656:5: note: candidate: ‘template<class _Tp> constexpr const _Tp& std::clamp(const _Tp&, const _Tp&, const _Tp&)’
 3656 |     clamp(const _Tp& __val, const _Tp& __lo, const _Tp& __hi)
      |     ^~~~~
/usr/include/c++/11/bits/stl_algo.h:3656:5: note:   template argument deduction/substitution failed:
answer.code:83:23: note:   deduced conflicting types for parameter ‘const _Tp’ (‘long int’ and ‘long long int’)
   83 |         tr.first=clamp(tr.first, 1ll,w1);
      |                  ~~~~~^~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/string:52,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from answer.code:1:
/usr/include/c++/11/bits/stl_algo.h:3674:5: note: candidate: ‘template<class _Tp, class _Compare> constexpr const _Tp& std::clamp(const _Tp&, const _Tp&, const _Tp&, _Compare)’
 3674 |     clamp(const _Tp& __val, const _Tp& __lo, const _Tp& __hi, _Compare __comp)
      |     ^~~~~
/usr/include/c++/11/bits/stl_algo.h:3674:5: note:   template argument deduction/substitution failed:
answer.code:83:23: note:   deduced conflicting types for parameter ‘const _Tp’ (‘long int’ and ‘long long int’)
   83 |         tr.first=clamp(tr.first, 1ll,w1);
      |                  ~~~~~^~~~~~~~~~~~~~~~~~