답안 #45455

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
45455 2018-04-14T06:59:56 Z Unit Gap (APIO16_gap) C++14
컴파일 오류
0 ms 0 KB
#include "gap.h"
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;

ll findGap(int t,ll n)
{
    ll s[100010];
    if(t == 1)
    {
        ll l = -1,r = 1001001001001001001;
        for(int i = 0; i < (n + 1) / 2; i++)
        {
            ll MAX,MIN;
            MinMax(l,r,&MIN,&MAX);
            s[i] = MIN;
            s[n - 1 - i] = MAX;
            l = MIN + 1;
            r = MAX - 1;
        }
        ll res = 0;
        for(int i = 1; i < n; i++)res = max(res,s[i] - s[i - 1]);
        return res;
    }
    else
    {
        ll L,R;
        MinMax(-1,1001001001001001001,&L,&R);
        vector<ll> ele;
        ele.push_back(L);
        ele.push_back(R);
        L++,R--;
        ll MIN,MAX,dif = R - L + 1;
        ll now = L;
        for(int i = 0; i < dif % n; i++)
        {
            MinMax(now,now + dif / n,&MIN,&MAX);
            if(MIN != -1)
            {
                ele.push_back(MIN);
                ele.push_back(MAX);
            }
            now = now + dif / n + 1;
        }
        for(int i = 0; i < n - dif % n; i++)
        {
            MinMax(now,now + dif / n - 1,&MIN,&MAX);
            if(MIN != -1)
            {
                ele.push_back(MIN);
                ele.push_back(MAX);
            }
            now = now + dif / n;
        }
        sort(ele.begin(),ele.end());
        ll res = 0;
        for(int i = 1; i < ele.size(); i++)res = max(res,ele[i] - ele[i - 1]);
        return res;
    }
}

Compilation message

gap.cpp: In function 'll findGap(int, ll)':
gap.cpp:58:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int i = 1; i < ele.size(); i++)res = max(res,ele[i] - ele[i - 1]);
                        ~~^~~~~~~~~~~~
/tmp/ccMIqJqK.o: In function `main':
grader.cpp:(.text.startup+0x18e): undefined reference to `findGap(int, int)'
collect2: error: ld returned 1 exit status