QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#723084#9221. Missing BoundarieslvliangCompile Error//C++142.1kb2024-11-07 21:08:012024-11-07 21:08:06

Judging History

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

  • [2024-11-07 21:08:06]
  • 评测
  • [2024-11-07 21:08:01]
  • 提交

answer

#include <iostream>
#include <cstring>
#include <algorithm>
#include <map>
#define fi first
#define se second
using namespace std;
const int N = 2e5 + 10;
typedef pair<int, int> PII;

PII pa[N];

void solve() {
    int n, L;
    scanf("%d%d", &n, &L);
    int un_def = 0;
    int idx = 0;
    map<int, int> mp;
    for (int i = 0; i < n; i++) {
        int x, y;
        scanf("%d%d", &x, &y);
        if (y == -1 && x == -1) un_def++;
        else {
            if (x == -1) x = y, mp[x] = 1;
            if (y == -1) y = x, mp[x] = 2;
            pa[idx++] = { x, y };
        }
    }
    sort(pa, pa + idx);
    for (int i = 1; i < idx; i++) {
        if (pa[i].fi <= pa[i - 1].se) {
            puts("NIE");
            return;
        }
    }
    int r = 0;
    // int st = L;
    // for (int i = 0; i < idx; i++) {
    //     if (i && pa[i - 1].se == -1) {
    //         //r += pa[i].fi - pa[i - 1].se - 1;
    //         r += pa[i - 1].fi - pa[i].fi - 1;
    //     } else if (pa[i].fi < st) {
    //         l += st - pa[i].fi;
    //     }
    //     if (pa[i].se != -1) {
    //         st = pa[i].se - 1;
    //     }
    // }
    // if (pa[idx - 1].se == -1) {
    //     r += pa[idx - 1].fi - 1;
    // } else l += pa[idx - 1].se - 1;
    int st = 1;
    for (int i = 0; i < idx; i++) {
        if (pa[i].fi > st) {
            if (mp[pa[i].fi] == 1) {
                r += pa[i].fi - st;
                st = pa[i].fi + 1;
            } else if (--un_def == -1) {
                puts("NIE");
                return;
            }
        }
        if (i + 1 == idx) break;
        if (mp[pa[i].fi] == 2) {
            st = pa[i + 1].fi;
            r += st - pa[i].fi - 1;
        } else {
            st = pa[i].se + 1;
        }
    }
    if (pa[idx - 1] == -1) {
        r += L - pa[idx - 1].fi;
    } else if (pa[i].se < L) {
        if (--un_def == -1) {
            puts("NIE");
            return;
        }
    }
    if (un_def <= r) puts("TAK");
    else puts("NIE");
}

int main() {
    int T;
    scanf("%d", &T);
    while (T--) {
        solve();
    }
    return 0;
}

Details

answer.code: In function ‘void solve()’:
answer.code:71:21: error: no match for ‘operator==’ (operand types are ‘PII’ {aka ‘std::pair<int, int>’} and ‘int’)
   71 |     if (pa[idx - 1] == -1) {
      |         ~~~~~~~~~~~ ^~ ~~
      |                   |    |
      |                   |    int
      |                   PII {aka std::pair<int, int>}
In file included from /usr/include/c++/13/iosfwd:42,
                 from /usr/include/c++/13/ios:40,
                 from /usr/include/c++/13/ostream:40,
                 from /usr/include/c++/13/iostream:41,
                 from answer.code:1:
/usr/include/c++/13/bits/postypes.h:192:5: note: candidate: ‘template<class _StateT> bool std::operator==(const fpos<_StateT>&, const fpos<_StateT>&)’
  192 |     operator==(const fpos<_StateT>& __lhs, const fpos<_StateT>& __rhs)
      |     ^~~~~~~~
/usr/include/c++/13/bits/postypes.h:192:5: note:   template argument deduction/substitution failed:
answer.code:71:25: note:   ‘PII’ {aka ‘std::pair<int, int>’} is not derived from ‘const std::fpos<_StateT>’
   71 |     if (pa[idx - 1] == -1) {
      |                         ^
In file included from /usr/include/c++/13/string:43,
                 from /usr/include/c++/13/bits/locale_classes.h:40,
                 from /usr/include/c++/13/bits/ios_base.h:41,
                 from /usr/include/c++/13/ios:44:
/usr/include/c++/13/bits/allocator.h:237:5: note: candidate: ‘template<class _T1, class _T2> bool std::operator==(const allocator<_CharT>&, const allocator<_T2>&)’
  237 |     operator==(const allocator<_T1>&, const allocator<_T2>&)
      |     ^~~~~~~~
/usr/include/c++/13/bits/allocator.h:237:5: note:   template argument deduction/substitution failed:
answer.code:71:25: note:   ‘PII’ {aka ‘std::pair<int, int>’} is not derived from ‘const std::allocator<_CharT>’
   71 |     if (pa[idx - 1] == -1) {
      |                         ^
In file included from /usr/include/c++/13/string:48:
/usr/include/c++/13/bits/stl_iterator.h:448:5: note: candidate: ‘template<class _Iterator> bool std::operator==(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)’
  448 |     operator==(const reverse_iterator<_Iterator>& __x,
      |     ^~~~~~~~
/usr/include/c++/13/bits/stl_iterator.h:448:5: note:   template argument deduction/substitution failed:
answer.code:71:25: note:   ‘PII’ {aka ‘std::pair<int, int>’} is not derived from ‘const std::reverse_iterator<_Iterator>’
   71 |     if (pa[idx - 1] == -1) {
      |                         ^
/usr/include/c++/13/bits/stl_iterator.h:493:5: note: candidate: ‘template<class _IteratorL, class _IteratorR> bool std::operator==(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)’
  493 |     operator==(const reverse_iterator<_IteratorL>& __x,
      |     ^~~~~~~~
/usr/include/c++/13/bits/stl_iterator.h:493:5: note:   template argument deduction/substitution failed:
answer.code:71:25: note:   ‘PII’ {aka ‘std::pair<int, int>’} is not derived from ‘const std::reverse_iterator<_Iterator>’
   71 |     if (pa[idx - 1] == -1) {
      |                         ^
/usr/include/c++/13/bits/stl_iterator.h:1678:5: note: candidate: ‘template<class _IteratorL, class _IteratorR> bool std::operator==(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)’
 1678 |     operator==(const move_iterator<_IteratorL>& __x,
      |     ^~~~~~~~
/usr/include/c++/13/bits/stl_iterator.h:1678:5: note:   template argument deduction/substitution failed:
answer.code:71:25: note:   ‘PII’ {aka ‘std::pair<int, int>’} is not derived from ‘const std::move_iterator<_IteratorL>’
   71 |     if (pa[idx - 1] == -1) {
      |                         ^
/usr/include/c++/13/bits/stl_iterator.h:1748:5: note: candidate: ‘template<class _Iterator> bool std::operator==(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)’
 1748 |     operator==(const move_iterator<_Iterator>& __x,
      |     ^~~~~~~~
/usr/include/c++/13/bits/stl_iterator.h:1748:5: note:   template argument deduction/substitution failed:
answer.code:71:25: note:   ‘PII’ {aka ‘std::pair<int, int>’} is not derived from ‘const std::move_iterator<_IteratorL>’
   71 |     if (pa[idx - 1] == -1) {
      |                         ^
In file included from /usr/include/c++/13/bits/stl_algobase.h:64,
                 from /usr/include/c++/13/string:51:
/usr/include/c++/13/bits/stl_pair.h:812:5: note: candidate: ‘template<class _T1, class _T2> constexpr bool std::operator==(const pair<_T1, _T2>&, const pair<_T1, _T2>&)’
  812 |     operator==(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
      |     ^~~~~~~~
/usr/include/c++/13/bits/stl_pair.h:812:5: note:   template argument deduction/substitution failed:
answer.code:71:25: note:   mismatched types ‘const std::pair<_T1, _T2>’ and ‘int’
   71 |     if (pa[idx - 1] == -1) {
      |                         ^
In file included from /usr/include/c++/13/string:54:
/usr/include/c++/13/bits/basic_string.h:3698:5: note: candida...