QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#5029#460. Colored GraphLenstarCompile Error//C++112.0kb2020-10-20 14:49:182021-12-19 05:45:07

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2021-12-19 05:45:07]
  • 评测
  • [2020-10-20 14:49:18]
  • 提交

answer

#include <bits/stdc++.h>

const int N = 5e5 + 10;
using pii = std::pair<int, int>;
using sit = std::set<int>::iterator;
#define mkp(a, b) std::make_pair(a, b)

inline long long read()
{
    long long x = 0;
    char ch = getchar();
    while (!isdigit(ch)) ch = getchar();
    while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
    return x;
}

std::unordered_map<pii, int> Map;
long long X, Y, Z, P[N];
pii ans[N];
int cnt = 0;
std::set<int> A, B;

inline int calc(int u, int v)
{
    return (X * std::min(u, v) + Y * std::max(u, v)) % Z >= P[u] + P[v];
}

inline int Ask(int u, int v)
{
    if (u > v) std::swap(u, v);
    return Map.count(mkp(u, v)) ? Map[mkp(u, v)] : calc(u, v);
}

inline int pre(int u)
{
    sit it = A.lower_bound(u); 
    if (it == A.begin()) it = A.end();
    return *--it;
}

inline int suf(int u)
{
    sit it = A.upper_bound(u);
    if (it == A.end()) it = A.begin();
    return *it;
}

inline void upd(int u)
{
    int p = pre(u), s = suf(u);
    if (Ask(u, p) != Ask(u, s)) B.insert(u);
    else if (B.find(u) != B.end()) B.erase(u);
}

inline int solve()
{
    if (B.empty())
    {
        sit it1 = A.begin(), it2 = it1; 
        int col = Ask(*it1, *++it2);
        for (; it2 != A.end(); it1 = it2++)
            printf("%d %d\n", *it1, *it2);
        return col;
    }
    int u = *B.begin(), p = pre(u), s = suf(u);
    int col1 = Ask(u, p);
    A.erase(u), B.erase(B.begin()), upd(p), upd(s);
    int col = solve();
    printf("%d %d\n", u, col1 == col ? p : s);
    return col;
}

int main()
{
    int n = read(), m = read();
    for (int i = 1; i <= m; ++i)
    {
        int u = read(), v = read();
        if (u > v) std::swap(u, v);
        Map[mkp(u, v)] = read();
    }
    X = read(), Y = read(), Z = read();
    for (int i = 1; i <= n; ++i) P[i] = read();
    for (int i = 1; i <= n; ++i) A.insert(i);
    for (int i = 1; i <= n; ++i) upd(i);
    return solve(), 0;
}

Details

answer.code:17:30: error: use of deleted function ‘std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map() [with _Key = std::pair<int, int>; _Tp = int; _Hash = std::hash<std::pair<int, int> >; _Pred = std::equal_to<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >]’
   17 | std::unordered_map<pii, int> Map;
      |                              ^~~
In file included from /usr/include/c++/10/unordered_map:47,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:117,
                 from answer.code:1:
/usr/include/c++/10/bits/unordered_map.h:141:7: note: ‘std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map() [with _Key = std::pair<int, int>; _Tp = int; _Hash = std::hash<std::pair<int, int> >; _Pred = std::equal_to<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >]’ is implicitly deleted because the default definition would be ill-formed:
  141 |       unordered_map() = default;
      |       ^~~~~~~~~~~~~
/usr/include/c++/10/bits/unordered_map.h:141:7: error: use of deleted function ‘std::_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, _H1, _H2, _Hash, _RehashPolicy, _Traits>::_Hashtable() [with _Key = std::pair<int, int>; _Value = std::pair<const std::pair<int, int>, int>; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<std::pair<int, int> >; _H1 = std::hash<std::pair<int, int> >; _H2 = std::__detail::_Mod_range_hashing; _Hash = 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++/10/unordered_map:46,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:117,
                 from answer.code:1:
/usr/include/c++/10/bits/hashtable.h:451:7: note: ‘std::_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, _H1, _H2, _Hash, _RehashPolicy, _Traits>::_Hashtable() [with _Key = std::pair<int, int>; _Value = std::pair<const std::pair<int, int>, int>; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<std::pair<int, int> >; _H1 = std::hash<std::pair<int, int> >; _H2 = std::__detail::_Mod_range_hashing; _Hash = 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:
  451 |       _Hashtable() = default;
      |       ^~~~~~~~~~
/usr/include/c++/10/bits/hashtable.h:451:7: error: use of deleted function ‘std::__detail::_Hashtable_base<_Key, _Value, _ExtractKey, _Equal, _H1, _H2, _Hash, _Traits>::_Hashtable_base() [with _Key = std::pair<int, int>; _Value = std::pair<const std::pair<int, int>, int>; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<std::pair<int, int> >; _H1 = std::hash<std::pair<int, int> >; _H2 = std::__detail::_Mod_range_hashing; _Hash = std::__detail::_Default_ranged_hash; _Traits = std::__detail::_Hashtable_traits<true, false, true>]’
In file included from /usr/include/c++/10/bits/hashtable.h:35,
                 from /usr/include/c++/10/unordered_map:46,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:117,
                 from answer.code:1:
/usr/include/c++/10/bits/hashtable_policy.h:1791:5: note: ‘std::__detail::_Hashtable_base<_Key, _Value, _ExtractKey, _Equal, _H1, _H2, _Hash, _Traits>::_Hashtable_base() [with _Key = std::pair<int, int>; _Value = std::pair<const std::pair<int, int>, int>; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<std::pair<int, int> >; _H1 = std::hash<std::pair<int, int> >; _H2 = std::__detail::_Mod_range_hashing; _Hash = std::__detail::_Default_ranged_hash; _Traits = std::__detail::_Hashtable_traits<true, false, true>]’ is implicitly deleted because the default definition would be ill-formed:
 1791 |     _Hashtable_base() = default;
      |     ^~~~~~~~~~~~~~~
/usr/include/c++/10/bits/hashtable_policy.h:1791:5: error: use of deleted function ‘std::__detail::_Hash_code_base<_Key, _Value, _ExtractKey, _H1, _H2, std::__detail::_Default_ranged_hash, true>::_Hash_code_base() [with _Key = std::pair<int, int>; _Value = std::pair<const std::pair<int, int>, int>; _ExtractKey = std::__detail::_Select1st; _H1 = std::hash<std::pair<int, int> >; _H2 = std::__detail::_Mod_range_hashing]’
/usr/include/c++/10/bits/hashtable_policy.h:1368:7: note: ‘std::__detail::_Hash_code_base<_Key, _Value, _ExtractKey, _H1, _H2, std::__detail::_Default_ranged_hash, true>::_Hash_code_base() [with _Key = std::pair<int, int>; _Value = std::pair<const std::pair<int, int>, int>; _ExtractKey = std::__detail::_Select1st; _H1 = std::hash<std::pair<int, int> >; _H2 = std::__detail::_Mod_range_hashing]’ i...