Submission #658927

#TimeUsernameProblemLanguageResultExecution timeMemory
658927Jeff12345121Horses (IOI15_horses)C++14
17 / 100
13 ms8532 KiB
#include <bits/stdc++.h>
#include "horses.h"

#define REP(i,n) for(int i = 1; i <= (n); i++)
using namespace std;

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

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

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

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

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

    return  max_sol % MOD;
}

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

    return  max_sol % MOD;
}
#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 (stderr)

horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:28:21: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   28 |     return  max_sol % MOD;
      |             ~~~~~~~~^~~~~
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:38:21: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   38 |     return  max_sol % MOD;
      |             ~~~~~~~~^~~~~
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:49:21: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   49 |     return  max_sol % MOD;
      |             ~~~~~~~~^~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...