제출 #31077

#제출 시각아이디문제언어결과실행 시간메모리
31077WhipppedCream친구 (IOI14_friend)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h>
#define ii pair<int, int>
#define X first
#define Y second
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define vii vector< pair<int, int> >
typedef long long ll;
using namespace std;
int Host[100005];
int Prot[100005];
int conf[100005];
int c[100005];
int nc[100005];
int main()
{
    int n; scanf("%d", &n);
    for(int i = 0; i< n; i++) scanf("%d", conf+i), c[i] = conf[i];
    for(int i = 1; i< n; i++) scanf("%d %d", Host+i, Prot+i);
    for(int i = n-1; i>= 1; i--)
    {
        int x = Host[i];
        if(Prot[i] == 1)
        {
            c[x] = max(max(c[x]+nc[i], c[i]+nc[x]), c[i]+c[x]);
            nc[x] = nc[x] + nc[i];
        }
        else if(Prot[i] == 2)
        {
            c[x] = max(c[x]+nc[i], c[i]+nc[x]);
            nc[x] = nc[x]+nc[i];
        }
        else
        {
            c[x] = c[x]+nc[i];
            nc[x] = max(c[i]+nc[x], nc[i]+nc[x]);
        }
    }
    printf("%d\n", max(c[0], nc[0]));
	return 0;
}

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

friend.cpp: In function 'int main()':
friend.cpp:18:27: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     int n; scanf("%d", &n);
                           ^
friend.cpp:19:66: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(int i = 0; i< n; i++) scanf("%d", conf+i), c[i] = conf[i];
                                                                  ^
friend.cpp:20:61: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(int i = 1; i< n; i++) scanf("%d %d", Host+i, Prot+i);
                                                             ^
/tmp/ccB7Bk6J.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/ccIqTix5.o:friend.cpp:(.text.startup+0x0): first defined here
/tmp/ccB7Bk6J.o: In function `main':
grader.cpp:(.text.startup+0xba): undefined reference to `findSample(int, int*, int*, int*)'
collect2: error: ld returned 1 exit status