QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#386939#6746. Merge the Rectanglesk1nsomCompile Error//C++174.2kb2024-04-11 21:47:162024-04-11 21:47:17

Judging History

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

  • [2024-04-11 21:47:17]
  • 评测
  • [2024-04-11 21:47:16]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define N 300005
#define ednl '\n'
#define int long long
int n, m, a[1510][1510] = {0}, b[1510][1510] = {0}, cnt[1510][1510] = {0};
bool vis[1510][1510] = {0};
unordered_map<pair<pair<int, int>, pair<int, int>>, int> js;
struct ra
{
    int space, sx, sy, tx, ty;
    bool operator>(const ra &a) const
    {
        if (space == a.space)
            return sx > a.sx;
        return space > a.space;
    }
} tmp;
priority_queue<ra, vector<ra>, greater<ra>> q;
set<pair<pair<int, int>, pair<int, int>>> s1, s2;
vector<ra> v;
signed main()
{
    cin >> n >> m;
    for (int i = 1; i < n; i++)
        for (int j = 1; j <= m; j++)
        {
            char c;
            cin >> c;
            a[i][j] = c - '0';
        }
    for (int i = 1; i <= n; i++)
        for (int j = 1; j < m; j++)
        {
            char c;
            cin >> c;
            b[i][j] = c - '0';
        }
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= m; j++)
            if (!vis[i][j])
            {
                vis[i][j] = 1;
                int sx = i, sy = j, tx = i, ty = j;
                while (tx <= n && !a[tx][j])
                {
                    tx++;
                    if (tx > n)
                    {
                        tx--;
                        break;
                    }
                }
                while (ty <= m && !b[i][ty])
                {
                    ty++;
                    if (ty > m)
                    {
                        ty--;
                        break;
                    }
                }
                ra tmp = {(ty - sy + 1) * (tx - sx + 1), sx, sy, tx, ty};
                q.push(tmp);
                v.push_back(tmp);
                for (int t = i; t <= tx; t++)
                    for (int k = j; k <= ty; k++)
                        vis[t][k] = 1;
                s1.insert({{sx, tx}, {sy, ty}}); // s1记录
                s2.insert({{sy, ty}, {sx, tx}});
            }
    // for (auto u : v)
    // {
    // cout << u.space << ' ' << u.sx << ' ' << u.sy << ' ' << u.tx << ' ' << u.ty << endl;
    //}
    // cout << "分割\n";
    while (!q.empty())
    {
        ra u = q.top();
        q.pop();
        s1.erase({{u.sx, u.tx}, {u.sy, u.ty}});
        s2.erase({{u.sy, u.ty}, {u.sx, u.tx}});
        if (js[{{u.sx, u.sy}, {u.tx, u.ty}}])
            continue;
        // cout << u.space << ' ' << u.sx << ' ' << u.sy << ' ' << u.tx << ' ' << u.ty << endl;
        if (u.sx == 1 && u.sy == 1 && u.tx == n && u.ty == m)
        {
            cout << "YES" << endl;

            exit(0);
        }
        auto x = *s1.lower_bound({{u.sx, u.tx}, {0, 0}});
        // cout << x.first.first << ' ' << x.first.second << ' ' << x.second.first << ' ' << x.second.second << endl;
        if (x.first.first == u.sx && x.first.second == u.tx)
        {
            int ty = max(u.ty, x.second.second), tx = max(u.tx, x.first.second), sx = min(u.sx, x.first.first), sy = min(u.sy, x.second.first);
            // cout << sx << ' ' << sy << ' ' << tx << ' ' << ty << endl;
            q.push({(ty - sy + 1) * (tx - sx + 1), sx, sy, tx, ty});
            s1.erase(x);
            s1.insert({{sx, tx}, {sy, ty}}); // s1记录
            js[{{x.first.first, x.second.first}, {x.first.second, x.second.second}}] = 1;
            continue;
        }
        x = *s2.lower_bound({{u.sy, u.ty}, {0, 0}});
        // cout << x.first.first << ' ' << x.first.second << ' ' << x.second.first << ' ' << x.second.second << endl;
        if (x.first.first == u.sy && x.first.second == u.ty)
        {
            int ty = max(u.ty, x.first.second), tx = max(u.tx, x.second.second), sx = min(u.sx, x.second.first), sy = min(u.sy, x.first.first);
            q.push({(ty - sy + 1) * (tx - sx + 1), sx, sy, tx, ty});
            s2.erase(x);
            s2.insert({{sy, ty}, {sx, tx}});
            js[{{x.first.second, x.second.second}, {x.first.first, x.second.first}}] = 1;
            continue;
        }
        s1.insert({{u.sx, u.tx}, {u.sy, u.ty}});
        s2.insert({{u.sy, u.ty}, {u.sx, u.tx}});
    }
    cout << "NO" << endl;
    return 0;
}

Details

answer.code:8:58: error: use of deleted function ‘std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map() [with _Key = std::pair<std::pair<long long int, long long int>, std::pair<long long int, long long int> >; _Tp = long long int; _Hash = std::hash<std::pair<std::pair<long long int, long long int>, std::pair<long long int, long long int> > >; _Pred = std::equal_to<std::pair<std::pair<long long int, long long int>, std::pair<long long int, long long int> > >; _Alloc = std::allocator<std::pair<const std::pair<std::pair<long long int, long long int>, std::pair<long long int, long long int> >, long long int> >]’
    8 | unordered_map<pair<pair<int, int>, pair<int, int>>, int> js;
      |                                                          ^~
In file included from /usr/include/c++/13/unordered_map:41,
                 from /usr/include/c++/13/functional:63,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:53,
                 from answer.code:1:
/usr/include/c++/13/bits/unordered_map.h:148:7: note: ‘std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map() [with _Key = std::pair<std::pair<long long int, long long int>, std::pair<long long int, long long int> >; _Tp = long long int; _Hash = std::hash<std::pair<std::pair<long long int, long long int>, std::pair<long long int, long long int> > >; _Pred = std::equal_to<std::pair<std::pair<long long int, long long int>, std::pair<long long int, long long int> > >; _Alloc = std::allocator<std::pair<const std::pair<std::pair<long long int, long long int>, std::pair<long long int, long long int> >, long long int> >]’ is implicitly deleted because the default definition would be ill-formed:
  148 |       unordered_map() = default;
      |       ^~~~~~~~~~~~~
/usr/include/c++/13/bits/unordered_map.h:148:7: error: use of deleted function ‘std::_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>::_Hashtable() [with _Key = std::pair<std::pair<long long int, long long int>, std::pair<long long int, long long int> >; _Value = std::pair<const std::pair<std::pair<long long int, long long int>, std::pair<long long int, long long int> >, long long int>; _Alloc = std::allocator<std::pair<const std::pair<std::pair<long long int, long long int>, std::pair<long long int, long long int> >, long long int> >; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<std::pair<std::pair<long long int, long long int>, std::pair<long long int, long long int> > >; _Hash = std::hash<std::pair<std::pair<long long int, long long int>, std::pair<long long int, long long int> > >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _RehashPolicy = std::__detail::_Prime_rehash_policy; _Traits = std::__detail::_Hashtable_traits<true, false, true>]’
In file included from /usr/include/c++/13/bits/unordered_map.h:33:
/usr/include/c++/13/bits/hashtable.h:530:7: note: ‘std::_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>::_Hashtable() [with _Key = std::pair<std::pair<long long int, long long int>, std::pair<long long int, long long int> >; _Value = std::pair<const std::pair<std::pair<long long int, long long int>, std::pair<long long int, long long int> >, long long int>; _Alloc = std::allocator<std::pair<const std::pair<std::pair<long long int, long long int>, std::pair<long long int, long long int> >, long long int> >; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<std::pair<std::pair<long long int, long long int>, std::pair<long long int, long long int> > >; _Hash = std::hash<std::pair<std::pair<long long int, long long int>, std::pair<long long int, long long int> > >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _RehashPolicy = std::__detail::_Prime_rehash_policy; _Traits = std::__detail::_Hashtable_traits<true, false, true>]’ is implicitly deleted because the default definition would be ill-formed:
  530 |       _Hashtable() = default;
      |       ^~~~~~~~~~
/usr/include/c++/13/bits/hashtable.h:530:7: error: use of deleted function ‘std::__detail::_Hashtable_base<_Key, _Value, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _Traits>::_Hashtable_base() [with _Key = std::pair<std::pair<long long int, long long int>, std::pair<long long int, long long int> >; _Value = std::pair<const std::pair<std::pair<long long int, long long int>, std::pair<long long int, long long int> >, long long int>; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<std::pair<std::pair<long long int, long long int>, std::pair<long long int, long long int> > >; _Hash = std::hash<std::pair<std::pair<long long int, long long int>, std::pair<long long int, long long int> > >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _Traits = std::__detail::_Hashtable_traits<true, false, true>]’
In...