답안 #658914

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
658914 2022-11-15T12:33:18 Z Jeff12345121 말 (IOI15_horses) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#define REP(i,n) for(int i = 1; i <= (n); i++)
#include "horses.h"
#define int long long
using namespace std;

#ifdef LOCAL
ifstream in("in.in");
ofstream out("out.out");
#endif

const int nmax = 1005;
int n,x[nmax],y[nmax],inf = (1LL << 60),MOD = 1000000007;

int init(int n, int tx[],int ty[]) {
    for (int i = 0; i < n; i++) {
        x[i] = tx[i];
        y[i] = ty[i];
    }

    int horses = 1,max_sol = -inf;
    for (int i = 0; i < n; i++) {
        horses = horses * x[i] % MOD;
        max_sol = max(max_sol , horses * y[i]);
    }

    return  max_sol;
}
int updateX(int pos, int val) {
    x[pos] = val;
    int horses = 1,max_sol = -inf;
    for (int i = 0; i < n; i++) {
        horses = horses * x[i] % MOD;
        max_sol = max(max_sol , horses * y[i]);
    }

    return  max_sol;
}

int updateY(int pos, int val) {
    y[pos] = val;
    int horses = 1,max_sol = -inf;
    for (int i = 0; i < n; i++) {
        horses = horses * x[i] % MOD;
        max_sol = max(max_sol , horses * y[i]);
    }

    return  max_sol;
}
#ifdef LOCAL
int tx[nmax],ty[nmax];
int32_t main() {
    in >> n;
    for (int i = 0; i < n; i++) {
        in >> tx[i];
    }
    for (int i = 0; i < n; i++) {
        in >> ty[i];
    }

    out << init(n,tx,ty) << "\n";
    int m;
    in >> m;
    for (int i = 0; i < m; i++) {
        int type,pos,val;
        in >> type >> pos >> val;
        if (type == 0) {
            out << updateX(pos, val);
        }
        if (type == 1) {
            out << updateY(pos,val);
        }
    }
}
#endif

Compilation message

horses.cpp: In function 'long long int init(long long int, long long int*, long long int*)':
horses.cpp:15:14: warning: declaration of 'n' shadows a global declaration [-Wshadow]
   15 | int init(int n, int tx[],int ty[]) {
      |              ^
horses.cpp:13:5: note: shadowed declaration is here
   13 | int n,x[nmax],y[nmax],inf = (1LL << 60),MOD = 1000000007;
      |     ^
/usr/bin/ld: /tmp/ccd7bQCY.o: in function `main':
grader.c:(.text.startup+0xaa): undefined reference to `init(int, int*, int*)'
/usr/bin/ld: grader.c:(.text.startup+0x113): undefined reference to `updateX(int, int)'
/usr/bin/ld: grader.c:(.text.startup+0x16d): undefined reference to `updateY(int, int)'
collect2: error: ld returned 1 exit status