제출 #1116202

#제출 시각아이디문제언어결과실행 시간메모리
1116202YugiHackerOvertaking (IOI23_overtaking)C++17
컴파일 에러
0 ms0 KiB
/*
	www.youtube.com/YugiHackerChannel
	linktr.ee/YugiHacker
*/

#ifndef function_only
#include "overtaking.h"
#endif // function_only

#include<bits/stdc++.h>
#define el cout<<"\n"
#define f0(i,n) for(int i=0;i<n;++i)
#define f1(i,n) for(int i=1;i<=n;++i)
#define maxn 1003

using namespace std;

int l, n, w[maxn], x, m, s[maxn];
long long t[maxn], y;

void init(int L, int N, long long T[], int W[], int X, int M, int S[])
{
    l = L, n = N;
    for (int i=0; i<n; i++) t[i] = T[i];
    for (int i=0; i<n; i++) w[i] = W[i];
    x = X;
    m = M;
    for (int i=0; i<m; i++) s[i] = S[i];
}

namespace sub1 {
    long long arr_time[2][maxn];

    long long solve() {
        t[n] = y;
        w[n] = x;
        for (int i=0; i<2; i++) arr_time[i][0] = t[i];
        //cout << m; el;
        //f0 (i, m) cout << s[i] << ' '; el;
        for (int i=1; i<m; i++)
        {
            for (int x=0; x<2; x++)
            {
                arr_time[x][i] = arr_time[x][i-1] + 1ll * (s[i] - s[i-1]) * w[x];
            }
            //cout << arr_time[0][i] << ' ' << arr_time[1][i], el;
            for (int x=0; x<2; x++) {
                if (arr_time[x][i-1] > arr_time[x^1][i-1] && arr_time[x][i] < arr_time[1^x][i])
                    arr_time[x][i] = arr_time[1^x][i];
            }
            //cout << arr_time[1][i] << ' '; el;
        }
        return arr_time[1][m-1];
    }
}


long long arrival_time(long long Y) {
    y = Y;
    if (n == 1) return sub1::solve();
}

#ifdef function_only
main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int l, n, x, m, q; cin >> l >> n >> x >> m >> q;
    long long t[n];
    for (int i=0; i<n; i++) cin >> t[i];
    for (int i=0; i<n; i++) cin >> w[i];
    for (int i=0; i<m; i++) cin >> s[i];
    init(l, n, t, w, x, m, s);
    while (q--) {
        long long y; cin >> y;
        cout << arrival_time(y) << '\n';
    }
}
#endif // function_only

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

overtaking.cpp: In function 'long long int arrival_time(long long int)':
overtaking.cpp:61:1: warning: control reaches end of non-void function [-Wreturn-type]
   61 | }
      | ^
/usr/bin/ld: /tmp/cczSx1PO.o: in function `main':
grader.cpp:(.text.startup+0x43e): undefined reference to `init(int, int, std::vector<long long, std::allocator<long long> >, std::vector<int, std::allocator<int> >, int, int, std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status