제출 #420959

#제출 시각아이디문제언어결과실행 시간메모리
420959marcipan5000친구 (IOI14_friend)C++17
컴파일 에러
0 ms0 KiB
#include "friend.h"
#include <vector>

bool q1=1,q2=1,q3=1;
int n1;
int ans=0;
int uu;

int conff[15];
vector<int> t[15];
bool z[15];
int w=0;
void rek(int p) {
    if (p==n1) {
        for (int i=0;i<n1;i++) {
            if (z[i]==1) {
                for (int j=0;j<t[i].size();j++) {
                    if (z[t[i][j]]==1) {
                        return;
                    }
                }
            }
        }
        ans=max(ans,w);
        return;
    }
    z[p]=0;
    rek(p+1);
    z[p]=1; w+=conff[p];
    rek(p+1);
    z[p]=0; w-=conff[p];
    return;
}

int findSample(int n,int confidence[],int host[],int protocol[]) {
    n1=n;
    for (int i=1;i<n;i++) {
        if (protocol[i]!=0) {
            q1=0;
        }
        if (protocol[i]!=1) {
            q2=0;
        }
        if (protocol[i]!=2) {
            q3=0;
        }
    }
    if (q3==1) {
        int ma=0;
        for (int i=0;i<n;i++) {
            ma=max(ma,confidence[i]);
        }
        return(ma);
    }
    if (n<=10) {
        for (int i=0;i<n;i++) {
            conff[i]=confidence[i];
        }
        for (int i=1;i<n;i++) {
            if (protocol[i]==0) {
               t[i].push_back(host[i]);
               t[host[i]].push_back(i);
            }
            if (protocol[i]==1) {
                uu=t[host[i]].size();
                for (int j=0;j<uu;j++) {
                    t[i].push_back(t[host[i]][j]);
                    t[t[host[i]][j]].push_back(i);
                }
            }
            if (protocol[i]==2) {
                uu=t[host[i]].size();
                for (int j=0;j<uu;j++) {
                    t[i].push_back(t[host[i]][j]);
                    t[t[host[i]][j]].push_back(i);
                }
                t[i].push_back(host[i]);
                t[host[i]].push_back(i);
            }

            /*
            for (int i2=0;i2<=i;i2++) {
                for (int j=0;j<t[i2].size();j++) {
                    cout << t[i2][j] << " ";
                }
                    cout << endl;
                }
            cout << endl;
            */
        }

        rek(0);
        return(ans);
    }
}

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

friend.cpp:10:1: error: 'vector' does not name a type
   10 | vector<int> t[15];
      | ^~~~~~
friend.cpp: In function 'void rek(int)':
friend.cpp:17:32: error: 't' was not declared in this scope
   17 |                 for (int j=0;j<t[i].size();j++) {
      |                                ^
friend.cpp:24:13: error: 'max' was not declared in this scope; did you mean 'std::max'?
   24 |         ans=max(ans,w);
      |             ^~~
      |             std::max
In file included from /usr/include/c++/10/vector:60,
                 from friend.cpp:2:
/usr/include/c++/10/bits/stl_algobase.h:300:5: note: 'std::max' declared here
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
friend.cpp: In function 'int findSample(int, int*, int*, int*)':
friend.cpp:51:16: error: 'max' was not declared in this scope; did you mean 'std::max'?
   51 |             ma=max(ma,confidence[i]);
      |                ^~~
      |                std::max
In file included from /usr/include/c++/10/vector:60,
                 from friend.cpp:2:
/usr/include/c++/10/bits/stl_algobase.h:300:5: note: 'std::max' declared here
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
friend.cpp:61:16: error: 't' was not declared in this scope
   61 |                t[i].push_back(host[i]);
      |                ^
friend.cpp:65:20: error: 't' was not declared in this scope
   65 |                 uu=t[host[i]].size();
      |                    ^
friend.cpp:72:20: error: 't' was not declared in this scope
   72 |                 uu=t[host[i]].size();
      |                    ^
friend.cpp:95:1: warning: control reaches end of non-void function [-Wreturn-type]
   95 | }
      | ^