QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#214312#5114. Cells Coloringucup-team1001Compile Error//C++206.1kb2023-10-14 18:45:012023-10-14 18:45:01

Judging History

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

  • [2023-10-14 18:45:01]
  • 评测
  • [2023-10-14 18:45:01]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;
#define ll long long
#define int ll

#define rep(i, a, b) for(int i = (a); i <= (b); ++i)
#define per(i, a, b) for(int i = (a); i >= (b); --i)

vector<string> mp;
#define PRINT(x) cout<<#x<<':';print(x);

void print(map<int, set<int>> mp) {
    cout << '{';
    for (auto [x, y]: mp) {
        cout << x << ':';
        cout << '{';
        for (auto i: y) {
            cout << i << ",";
        }
        cout << '}';
    }
    cout << '}' << endl;
}

void print(map<int, set<pair<int, int>>> mp) {
    cout << '{';
    for (auto [x, y]: mp) {
        cout << x << ':';
        cout << '{';
        for (auto [i, j]: y) {
            cout << '{' << i << "," << j << "},";
        }
        cout << '}';
    }
    cout << '}' << endl;
}

signed main() {
    int n, m, c, d;
    cin >> n >> m >> c >> d;
    map<int, set<int>> row, col;
    map<int, set<pair<int, int>>> prow, pcol, pboth;
    unsigned int maxk = 0;
    rep(i, 0, n - 1) {
        string s;
        cin >> s;
        mp.emplace_back(s);
    }
    rep(i, 0, n - 1) {
        rep(j, 0, m - 1) {
            if (mp[i][j] == '.') {
                row[i].emplace(j);
            }
        }
        maxk = max(maxk, row[i].size());
        rep(j, 0, m - 1) {
            if (mp[i][j] == '.') {
                prow[row[i].size()].emplace(i, j);
            }
        }
    }
    rep(j, 0, m - 1) {
        rep(i, 0, n - 1) {
            if (mp[i][j] == '.') {
                col[j].emplace(i);
            }
        }
        maxk = max(maxk, col[j].size());
        rep(i, 0, n - 1) {
            if (mp[i][j] == '.') {
                pcol[col[j].size()].emplace(i, j);
                if (prow[col[j].size()].contains({i, j})) {
                    pboth[col[j].size()].emplace(i, j);
                }
            }
        }
    }

//    cout<<1<<endl;
    int ans = c * maxk;
    int z = 0;
    per(k, maxk, 1) {
//        cout << "k:" << k << endl;
        auto tpboth = pboth[k];
        for (auto &&[x, y]: tpboth) {
            if (!pboth[k].contains({x, y}))continue;
            prow[row[x].size()].erase({x, y});
            pcol[col[y].size()].erase({x, y});
            pboth[k].erase({x, y});
            row[x].erase(y);
            col[y].erase(x);
            for (auto &&j: row[x]) {
                prow[row[x].size() + 1].erase({x, j});
                pboth[row[x].size() + 1].erase({x, j});
                prow[row[x].size()].emplace(x, j);
                if (pcol[row[x].size()].contains({x, j})) {
                    pboth[row[x].size()].emplace(x, j);
                }
            }
            for (auto &&i: col[y]) {
                pcol[col[y].size() + 1].erase({i, y});
                pboth[col[y].size() + 1].erase({i, y});
                pcol[col[y].size()].emplace(i, y);
                if (prow[col[y].size()].contains({i, y})) {
                    pboth[col[y].size()].emplace(i, y);
                }
            }
            z++;
//            cout << "del" << '{' << x << "," << y << "}:" << endl;
//            PRINT(row);
//            PRINT(col);
//            PRINT(prow);
//            PRINT(pcol);
//            PRINT(pboth);
//            cout << "z:" << z << endl;
        }

//        cout<<1<<endl;
        auto tprow = prow[k];
        for (auto &&[x, y]: tprow) {
            if (!prow[k].contains({x, y}))continue;
            prow[row[x].size()].erase({x, y});
            pcol[col[y].size()].erase({x, y});
            pboth[k].erase({x, y});
            row[x].erase(y);
            col[y].erase(x);
            for (auto &&j: row[x]) {
                prow[row[x].size() + 1].erase({x, j});
                pboth[row[x].size() + 1].erase({x, j});
                prow[row[x].size()].emplace(x, j);
                if (pcol[row[x].size()].contains({x, j})) {
                    pboth[row[x].size()].emplace(x, j);
                }
            }
            for (auto &&i: col[y]) {
                pcol[col[y].size() + 1].erase({i, y});
                pboth[col[y].size() + 1].erase({i, y});
                pcol[col[y].size()].emplace(i, y);
                if (prow[col[y].size()].contains({i, y})) {
                    pboth[col[y].size()].emplace(i, y);
                }
            }
            z++;
//            cout << "del" << '{' << x << "," << y << "}:" << endl;
//            PRINT(row);
//            PRINT(col);
//            PRINT(prow);
//            PRINT(pcol);
//            PRINT(pboth);
//            cout << "z:" << z << endl;
        }
        auto tpcol = pcol[k];
        for (auto &&[x, y]: tpcol) {
            if (!pcol[k].contains({x, y}))continue;
            prow[row[x].size()].erase({x, y});
            pcol[col[y].size()].erase({x, y});
            pboth[k].erase({x, y});
            row[x].erase(y);
            col[y].erase(x);
            for (auto &&j: row[x]) {
                prow[row[x].size() + 1].erase({x, j});
                pboth[row[x].size() + 1].erase({x, j});
                prow[row[x].size()].emplace(x, j);
                if (pcol[row[x].size()].contains({x, j})) {
                    pboth[row[x].size()].emplace(x, j);
                }
            }
            for (auto &&i: col[y]) {
                pcol[col[y].size() + 1].erase({i, y});
                pboth[col[y].size() + 1].erase({i, y});
                pcol[col[y].size()].emplace(i, y);
                if (prow[col[y].size()].contains({i, y})) {
                    pboth[col[y].size()].emplace(i, y);
                }
            }
            z++;
//            cout << "del" << '{' << x << "," << y << "}:" << endl;
//            PRINT(row);
//            PRINT(col);
//            PRINT(prow);
//            PRINT(pcol);
//            PRINT(pboth);
//            cout << "z:" << z << endl;
        }
//        cout << "ans:" << c * (k - 1) + d * z << endl;
        ans = min(ans, c * (k - 1) + d * z);
    }
//    cout<<1<<endl;
    cout << ans;
}
//3 4 2 1
//.***
//*..*
//**..
//
//3 4 1 2
//.***
//*..*
//**..

Details

answer.code: In function ‘int main()’:
answer.code:56:19: error: no matching function for call to ‘max(long long unsigned int&, std::set<long long int>::size_type)’
   56 |         maxk = max(maxk, row[i].size());
      |                ~~~^~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from answer.code:1:
/usr/include/c++/11/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++/11/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
answer.code:56:19: note:   deduced conflicting types for parameter ‘const _Tp’ (‘long long unsigned int’ and ‘std::set<long long int>::size_type’ {aka ‘long unsigned int’})
   56 |         maxk = max(maxk, row[i].size());
      |                ~~~^~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from answer.code:1:
/usr/include/c++/11/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++/11/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
answer.code:56:19: note:   deduced conflicting types for parameter ‘const _Tp’ (‘long long unsigned int’ and ‘std::set<long long int>::size_type’ {aka ‘long unsigned int’})
   56 |         maxk = max(maxk, row[i].size());
      |                ~~~^~~~~~~~~~~~~~~~~~~~~
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:3461:5: note: candidate: ‘template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)’
 3461 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/11/bits/stl_algo.h:3461:5: note:   template argument deduction/substitution failed:
answer.code:56:19: note:   mismatched types ‘std::initializer_list<_Tp>’ and ‘long long unsigned int’
   56 |         maxk = max(maxk, row[i].size());
      |                ~~~^~~~~~~~~~~~~~~~~~~~~
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:3467:5: note: candidate: ‘template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)’
 3467 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/11/bits/stl_algo.h:3467:5: note:   template argument deduction/substitution failed:
answer.code:56:19: note:   mismatched types ‘std::initializer_list<_Tp>’ and ‘long long unsigned int’
   56 |         maxk = max(maxk, row[i].size());
      |                ~~~^~~~~~~~~~~~~~~~~~~~~
answer.code:69:19: error: no matching function for call to ‘max(long long unsigned int&, std::set<long long int>::size_type)’
   69 |         maxk = max(maxk, col[j].size());
      |                ~~~^~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from answer.code:1:
/usr/include/c++/11/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++/11/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
answer.code:69:19: note:   deduced conflicting types for parameter ‘const _Tp’ (‘long long unsigned int’ and ‘std::set<long long int>::size_type’ {aka ‘long unsigne...