Submission #1091401

# Submission time Handle Problem Language Result Execution time Memory
1091401 2024-09-20T19:05:14 Z andrei_iorgulescu Joker (BOI20_joker) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>

using namespace std;

int n, m, q;
int u[200005], v[200005];
int rmin[200005];

pair<int, int> t[200005];
vector<int> g[200005];
int cnt_bad = 0;

pair<int, int> par(int x)
{
    int s1 = 0;
    while (t[x].first != x)
    {
        s1 += t[x].second;
        x = t[x].first;
    }
    return make_pair(x, s1 % 2);
}

bool viz[200005];

int kk, kkk;

void dfss(int x, int y)
{
    viz[x] = true;
    if (x == y)
        kkk = kk;
    else
    {
        for (auto vecin : g[x])
        {
            if (!viz[vecin])
            {
                kk = 1 - kk;
                dfss(vecin, y);
                kk = 1 - kk;
            }
        }
    }
}

void join(int x, int y)
{
    pair<int,int> p1 = par(x);
    pair<int,int> p2 = par(y);
    if (p1.first != p2.first)
    {
        t[p2.first] = make_pair(p1.first, (1 + p1.second + p2.second) % 2);
        int dl = t[p2.first].second;
        memset(viz, 0, sizeof(viz));
        kk = 0;
        kkk = 0;
        dfss(p2.first, p1.first);
        t[p2.first] = kkk;
    }
    else
    {
        if (p1.second == p2.second)
            cnt_bad++;
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin >> n >> m >> q;
    for (int i = 1; i <= m; i++)
        cin >> u[i] >> v[i], g[u[i]].push_back(v[i]), g[v[i]].push_back(u[i]);
    for (int i = 1; i <= n; i++)
        t[i] = {i, 0};
    rmin[1] = 1;
    for (int i = m; i >= 1; i--)
    {
        join(u[i], v[i]);
        if (cnt_bad != 0)
        {
            rmin[1] = i + 1;
            break;
        }
    }
    for (int i = 1; i <= q; i++)
    {
        int x, y;
        cin >> x >> y;
        if (y < rmin[x])
            cout << "YES\n";
        else
            cout << "NO\n";
    }
    return 0;
}

///wtfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff

/**
deci teoretic daca bag elementele de la 1 la N, apoi fac two pointers-ul, o sa cam am queue-like undoing pe DSU, pe care tin si ceva de bipartit
**/

Compilation message

Joker.cpp: In function 'void join(int, int)':
Joker.cpp:59:23: error: no match for 'operator=' (operand types are 'std::pair<int, int>' and 'int')
   59 |         t[p2.first] = kkk;
      |                       ^~~
In file included from /usr/include/c++/10/bits/stl_algobase.h:64,
                 from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from Joker.cpp:1:
/usr/include/c++/10/bits/stl_pair.h:390:7: note: candidate: 'std::pair<_T1, _T2>& std::pair<_T1, _T2>::operator=(typename std::conditional<std::__and_<std::is_copy_assignable<_T1>, std::is_copy_assignable<_T2> >::value, const std::pair<_T1, _T2>&, const std::__nonesuch&>::type) [with _T1 = int; _T2 = int; typename std::conditional<std::__and_<std::is_copy_assignable<_T1>, std::is_copy_assignable<_T2> >::value, const std::pair<_T1, _T2>&, const std::__nonesuch&>::type = const std::pair<int, int>&]'
  390 |       operator=(typename conditional<
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_pair.h:393:41: note:   no known conversion for argument 1 from 'int' to 'std::conditional<true, const std::pair<int, int>&, const std::__nonesuch&>::type' {aka 'const std::pair<int, int>&'}
  390 |       operator=(typename conditional<
      |                 ~~~~~~~~~~~~~~~~~~~~~    
  391 |   __and_<is_copy_assignable<_T1>,
      |   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~        
  392 |          is_copy_assignable<_T2>>::value,
      |          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  393 |   const pair&, const __nonesuch&>::type __p)
      |   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_pair.h:401:7: note: candidate: 'std::pair<_T1, _T2>& std::pair<_T1, _T2>::operator=(typename std::conditional<std::__and_<std::is_move_assignable<_Tp>, std::is_move_assignable<_T2> >::value, std::pair<_T1, _T2>&&, std::__nonesuch&&>::type) [with _T1 = int; _T2 = int; typename std::conditional<std::__and_<std::is_move_assignable<_Tp>, std::is_move_assignable<_T2> >::value, std::pair<_T1, _T2>&&, std::__nonesuch&&>::type = std::pair<int, int>&&]'
  401 |       operator=(typename conditional<
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_pair.h:404:31: note:   no known conversion for argument 1 from 'int' to 'std::conditional<true, std::pair<int, int>&&, std::__nonesuch&&>::type' {aka 'std::pair<int, int>&&'}
  401 |       operator=(typename conditional<
      |                 ~~~~~~~~~~~~~~~~~~~~~
  402 |   __and_<is_move_assignable<_T1>,
      |   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  403 |          is_move_assignable<_T2>>::value,
      |          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  404 |   pair&&, __nonesuch&&>::type __p)
      |   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_pair.h:418:2: note: candidate: 'template<class _U1, class _U2> typename std::enable_if<std::__and_<std::is_assignable<_T1&, const _U1&>, std::is_assignable<_T2&, const _U2&> >::value, std::pair<_T1, _T2>&>::type std::pair<_T1, _T2>::operator=(const std::pair<_U1, _U2>&) [with _U1 = _U1; _U2 = _U2; _T1 = int; _T2 = int]'
  418 |  operator=(const pair<_U1, _U2>& __p)
      |  ^~~~~~~~
/usr/include/c++/10/bits/stl_pair.h:418:2: note:   template argument deduction/substitution failed:
Joker.cpp:59:23: note:   mismatched types 'const std::pair<_T1, _T2>' and 'int'
   59 |         t[p2.first] = kkk;
      |                       ^~~
In file included from /usr/include/c++/10/bits/stl_algobase.h:64,
                 from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from Joker.cpp:1:
/usr/include/c++/10/bits/stl_pair.h:430:2: note: candidate: 'template<class _U1, class _U2> typename std::enable_if<std::__and_<std::is_assignable<_T1&, _U1&&>, std::is_assignable<_T2&, _U2&&> >::value, std::pair<_T1, _T2>&>::type std::pair<_T1, _T2>::operator=(std::pair<_U1, _U2>&&) [with _U1 = _U1; _U2 = _U2; _T1 = int; _T2 = int]'
  430 |  operator=(pair<_U1, _U2>&& __p)
      |  ^~~~~~~~
/usr/include/c++/10/bits/stl_pair.h:430:2: note:   template argument deduction/substitution failed:
Joker.cpp:59:23: note:   mismatched types 'std::pair<_T1, _T2>' and 'int'
   59 |         t[p2.first] = kkk;
      |                       ^~~
Joker.cpp:54:13: warning: unused variable 'dl' [-Wunused-variable]
   54 |         int dl = t[p2.first].second;
      |             ^~