답안 #255910

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
255910 2020-08-02T05:31:28 Z 반딧불(#5032) Joker (BOI20_joker) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")

using namespace std;

typedef long long ll;

struct data{
    int s, e, i;
    data(){}
    data(int s, int e, int i): s(s), e(e), i(i){}
};
vector<data> link[200002];

int n, m, q;
int l, r;

int chk[200002];

bool dfs(int x, int y = 1){
    chk[x] = y;
    for(auto &nxt: link[x]){
        if(l <= nxt.i && nxt.i <= r) continue;
        if(chk[nxt.e] == y) return true;
        if(chk[nxt.e] == 0) dfs(nxt.e, 3-y);
    }
    return false;
}

int main(){
    scanf("%d %d %d", &n, &m, &q);
    for(int i=1; i<=m; i++){
        int s, e;
        scanf("%d %d", &s, &e);
        link[s].push_back(data(s, e, i));
        link[e].push_back(data(e, s, i));
    }

    for(int i=1; i<=q; i++){
        scanf("%d %d", &l, &r);
        memset(chk, 0, sizeof(chk));

        bool possible = 0;
        for(int i=1; i<=n; i++){
            if(!chk[i] && dfs(i)){
                possible = 1;
                break;
            }
        }
        printf("%s\n", possible ? "YES" : "NO");
    }
}

Compilation message

Joker.cpp:14:12: error: template argument 1 is invalid
 vector<data> link[200002];
            ^
Joker.cpp:14:12: error: template argument 2 is invalid
Joker.cpp: In function 'bool dfs(int, int)':
Joker.cpp:23:26: error: 'begin' was not declared in this scope
     for(auto &nxt: link[x]){
                          ^
Joker.cpp:23:26: note: suggested alternatives:
In file included from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:95:0,
                 from Joker.cpp:1:
/usr/include/c++/7/valarray:1211:5: note:   'std::begin'
     begin(const valarray<_Tp>& __va)
     ^~~~~
/usr/include/c++/7/valarray:1211:5: note:   'std::begin'
Joker.cpp:23:26: error: 'end' was not declared in this scope
     for(auto &nxt: link[x]){
                          ^
Joker.cpp:23:26: note: suggested alternatives:
In file included from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:95:0,
                 from Joker.cpp:1:
/usr/include/c++/7/valarray:1231:5: note:   'std::end'
     end(const valarray<_Tp>& __va)
     ^~~
/usr/include/c++/7/valarray:1231:5: note:   'std::end'
Joker.cpp: In function 'int main()':
Joker.cpp:36:17: error: request for member 'push_back' in 'link[s]', which is of non-class type 'int'
         link[s].push_back(data(s, e, i));
                 ^~~~~~~~~
Joker.cpp:36:27: error: reference to 'data' is ambiguous
         link[s].push_back(data(s, e, i));
                           ^~~~
Joker.cpp:9:8: note: candidates are: struct data
 struct data{
        ^~~~
In file included from /usr/include/c++/7/string:51:0,
                 from /usr/include/c++/7/bits/locale_classes.h:40,
                 from /usr/include/c++/7/bits/ios_base.h:41,
                 from /usr/include/c++/7/ios:42,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from Joker.cpp:1:
/usr/include/c++/7/bits/range_access.h:318:5: note:                 template<class _Tp> constexpr const _Tp* std::data(std::initializer_list<_Tp>)
     data(initializer_list<_Tp> __il) noexcept
     ^~~~
/usr/include/c++/7/bits/range_access.h:309:5: note:                 template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])
     data(_Tp (&__array)[_Nm]) noexcept
     ^~~~
/usr/include/c++/7/bits/range_access.h:299:5: note:                 template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)
     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
     ^~~~
/usr/include/c++/7/bits/range_access.h:289:5: note:                 template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)
     data(_Container& __cont) noexcept(noexcept(__cont.data()))
     ^~~~
Joker.cpp:37:17: error: request for member 'push_back' in 'link[e]', which is of non-class type 'int'
         link[e].push_back(data(e, s, i));
                 ^~~~~~~~~
Joker.cpp:37:27: error: reference to 'data' is ambiguous
         link[e].push_back(data(e, s, i));
                           ^~~~
Joker.cpp:9:8: note: candidates are: struct data
 struct data{
        ^~~~
In file included from /usr/include/c++/7/string:51:0,
                 from /usr/include/c++/7/bits/locale_classes.h:40,
                 from /usr/include/c++/7/bits/ios_base.h:41,
                 from /usr/include/c++/7/ios:42,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from Joker.cpp:1:
/usr/include/c++/7/bits/range_access.h:318:5: note:                 template<class _Tp> constexpr const _Tp* std::data(std::initializer_list<_Tp>)
     data(initializer_list<_Tp> __il) noexcept
     ^~~~
/usr/include/c++/7/bits/range_access.h:309:5: note:                 template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])
     data(_Tp (&__array)[_Nm]) noexcept
     ^~~~
/usr/include/c++/7/bits/range_access.h:299:5: note:                 template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)
     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
     ^~~~
/usr/include/c++/7/bits/range_access.h:289:5: note:                 template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)
     data(_Container& __cont) noexcept(noexcept(__cont.data()))
     ^~~~
Joker.cpp:32:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d %d", &n, &m, &q);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
Joker.cpp:35:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %d", &s, &e);
         ~~~~~^~~~~~~~~~~~~~~~~
Joker.cpp:41:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %d", &l, &r);
         ~~~~~^~~~~~~~~~~~~~~~~