Submission #1001089

# Submission time Handle Problem Language Result Execution time Memory
1001089 2024-06-18T14:22:40 Z Ausp3x Horses (IOI15_horses) C++17
Compilation error
0 ms 0 KB
// 人外有人,天外有天
// author: Ausp3x

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include "horses.h"
typedef long long             lng;
typedef unsigned int          uint;
typedef unsigned long long    ulng;
using namespace std;
using namespace __gnu_pbds;

int const INF32 = 0x3f3f3f3f;
lng const INF64 = 0x3f3f3f3f3f3f3f3f;

int const MOD = 1000000007;

int N;
vector<int> X, Y;

int getMaxValue() {
    lng horses = 1;
    for (int i = 0; i < N; i++) {
        (horses *= X[i]) %= MOD;
        
        bool chk = true;
        lng cur = 1; 
        for (int j = i + 1; j < N; j++) {
            if (cur == INF32 || cur * X[j] > INF32) {
                chk = false;
                break;
            }
            cur *= X[j];

            if (cur * Y[j] > Y[i]) {
                chk = false;
                break;
            }
        }
            
        if (chk) {
            return horses * Y[i] % MOD;
        }
    }

    return -1;
}


int init(int n, vector<int> x, vector<int> y) {
    N = n;
    X = x;
    Y = y;

	return getMaxValue();
}

int updateX(int pos, int val) {	
    X[pos] = val;

	return getMaxValue();
}

int updateY(int pos, int val) {
    Y[pos] = val;

	return getMaxValue();
}

// int main() {
//     ios_base::sync_with_stdio(false);
//     cin.tie(NULL);

//     cout << init(3, {2, 1, 3}, {3, 4, 1}) << endl;
//     cout << updateY(1, 2) << endl;

//     return 0;
// }

Compilation message

horses.cpp: In function 'int getMaxValue()':
horses.cpp:42:34: warning: conversion from 'lng' {aka 'long long int'} to 'int' may change value [-Wconversion]
   42 |             return horses * Y[i] % MOD;
      |                    ~~~~~~~~~~~~~~^~~~~
/usr/bin/ld: /tmp/ccY8qYk4.o: in function `main':
grader.c:(.text.startup+0xaa): undefined reference to `init(int, int*, int*)'
collect2: error: ld returned 1 exit status