제출 #1040627

#제출 시각아이디문제언어결과실행 시간메모리
1040627Ausp3x친구 (IOI14_friend)C++17
컴파일 에러
0 ms0 KiB
// 人外有人,天外有天
// author: Ausp3x

#pragma GCC optimize("O1, O2, O3, Ofast, unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include "friend.h"
using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define pb push_back
// #define DEBUG
typedef long long    lng;

int const INF32 = 0x3f3f3f3f;
lng const INF64 = 0x3f3f3f3f3f3f3f3f;

int findSample(int n, int confidence[], int host[], int protocol[]) {
    vector<vector<int>> adjl(n);
    for (int i = 1; i < n; i++) {
        switch (protocol[i]) {
            case 0: // IAmYourFriend
                adjl[host[i]].pb(i);
                adjl[i].pb(host[i]);
                break;
            case 1: // MyFriendsAreYourFriends
                for (int j : adjl[host[i]]) {
                    adjl[j].pb(i);
                    adjl[i].pb(j);
                }        
                break;
            case 2: // WeAreYourFriends
                for (int j : adjl[host[i]]) {
                    adjl[j].pb(i);
                    adjl[i].pb(j);
                }
                adjl[host[i]].pb(i);
                adjl[i].pb(host[i]);
                break;
            default:
                return -1;
        }
    }

    if (n <= 10) {
        lng ans = 0;
        for (int msk = 0; msk < (1 << n); msk++) {
            vector<bool> vst(n);
            for (int i = 0; i < n; i++)
                vst[i] = msk & (1 << i);
            
            lng cur = 0;
            for (int i = 0; i < n; i++) {
                if (!vst[i])
                    continue;

                cur += confidence[i];

                for (int j : adjl[i])
                    if (vst[j])
                        goto exit;
            }

            ans = max(ans, cur);
        exit:;
        }

        return ans;
    }

    bool isAll0 = true, isAll1 = true, isAll2 = true;
    for (int i = 1; i < n; i++) {
        isAll0 &= protocol[i] == 0;
        isAll1 &= protocol[i] == 1;
        isAll2 &= protocol[i] == 2;
    }

    if (isAll1) {
        lng ans = 0;
        for (int i = 1; i < n; i++)
            ans = max(ans, confidence[i]);
        
        return ans;
    }

    

    return -1;
}

#ifdef DEBUG
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int t = 1;
    cin >> t;
    while (t--) {
        solve();
    }

    return 0;
}
#endif

컴파일 시 표준 에러 (stderr) 메시지

friend.cpp:4:55: warning: bad option '-f O2' to pragma 'optimize' [-Wpragmas]
    4 | #pragma GCC optimize("O1, O2, O3, Ofast, unroll-loops")
      |                                                       ^
friend.cpp:4:55: warning: bad option '-f O3' to pragma 'optimize' [-Wpragmas]
friend.cpp:4:55: warning: bad option '-f Ofast' to pragma 'optimize' [-Wpragmas]
friend.cpp:4:55: warning: bad option '-f unroll-loops' to pragma 'optimize' [-Wpragmas]
In file included from friend.cpp:7:
friend.h:7:64: warning: bad option '-f O2' to attribute 'optimize' [-Wattributes]
    7 | int findSample(int n,int confidence[],int host[],int protocol[]);
      |                                                                ^
friend.h:7:64: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
friend.h:7:64: warning: bad option '-f Ofast' to attribute 'optimize' [-Wattributes]
friend.h:7:64: warning: bad option '-f unroll-loops' to attribute 'optimize' [-Wattributes]
friend.h:7:64: warning: bad option '-f O2' to attribute 'optimize' [-Wattributes]
friend.h:7:64: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
friend.h:7:64: warning: bad option '-f Ofast' to attribute 'optimize' [-Wattributes]
friend.h:7:64: warning: bad option '-f unroll-loops' to attribute 'optimize' [-Wattributes]
friend.cpp:20:67: warning: bad option '-f O2' to attribute 'optimize' [-Wattributes]
   20 | int findSample(int n, int confidence[], int host[], int protocol[]) {
      |                                                                   ^
friend.cpp:20:67: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
friend.cpp:20:67: warning: bad option '-f Ofast' to attribute 'optimize' [-Wattributes]
friend.cpp:20:67: warning: bad option '-f unroll-loops' to attribute 'optimize' [-Wattributes]
friend.cpp: In function 'int findSample(int, int*, int*, int*)':
friend.cpp:83:41: error: no matching function for call to 'max(lng&, int&)'
   83 |             ans = max(ans, confidence[i]);
      |                                         ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from friend.cpp:5:
/usr/include/c++/10/bits/stl_algobase.h:254:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  254 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
friend.cpp:83:41: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   83 |             ans = max(ans, confidence[i]);
      |                                         ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from friend.cpp:5:
/usr/include/c++/10/bits/stl_algobase.h:300:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
friend.cpp:83:41: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   83 |             ans = max(ans, confidence[i]);
      |                                         ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from friend.cpp:5:
/usr/include/c++/10/bits/stl_algo.h:3480:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3480 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3480:5: note:   template argument deduction/substitution failed:
friend.cpp:83:41: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   83 |             ans = max(ans, confidence[i]);
      |                                         ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from friend.cpp:5:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3486:5: note:   template argument deduction/substitution failed:
friend.cpp:83:41: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   83 |             ans = max(ans, confidence[i]);
      |                                         ^