Submission #1039810

# Submission time Handle Problem Language Result Execution time Memory
1039810 2024-07-31T09:38:02 Z c2zi6 Horses (IOI15_horses) C++14
34 / 100
1500 ms 15960 KB
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define replr(i, a, b) for (int i = int(a); i <= int(b); ++i)
#define reprl(i, a, b) for (int i = int(a); i >= int(b); --i)
#define rep(i, n) for (int i = 0; i < int(n); ++i)
#define mkp(a, b) make_pair(a, b)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VPI;
typedef vector<VI> VVI;
typedef vector<VVI> VVVI;
typedef vector<VPI> VVPI;
typedef pair<ll, ll> PLL;
typedef vector<ll> VL;
typedef vector<PLL> VPL;
typedef vector<VL> VVL;
typedef vector<VVL> VVVL;
typedef vector<VPL> VVPL;
template<class T> T setmax(T& a, T b) {if (a < b) return a = b; return a;}
template<class T> T setmin(T& a, T b) {if (a < b) return a; return a = b;}
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<typename T>
using indset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#include "horses.h"

const ll MOD = 1e9 + 7;

int n;
VL a, b;

ll recalc() {
    ll leave = n;
    ll prod = 1;
    reprl(i, n-1, 0) {
        if (b[i] > prod) {
            prod = a[i] * b[i];
            leave = i;
        } else {
            prod = a[i] * prod;
        }
        if (prod > 1e9) prod = 1e9;
    }
    ll ans = 1;
    rep(i, n) {
        ans *= a[i];
        ans %= MOD;
        if (i == leave) {
            ans *= b[i];
            ans %= MOD;
            break;
        }
    }
	return ans;
}

int init(int N, int X[], int Y[]) {
    n = N;
    a = b = VL(n);
    rep(i, n) {
        a[i] = X[i];
        b[i] = Y[i];
    }
    return recalc();
}

int updateX(int pos, int val) {	
    a[pos] = val;
	return recalc();
}

int updateY(int pos, int val) {
    b[pos] = val;
	return recalc();
}


Compilation message

horses.cpp: In function 'll recalc()':
horses.cpp:49:13: warning: conversion from 'll' {aka 'long long int'} to 'double' may change value [-Wconversion]
   49 |         if (prod > 1e9) prod = 1e9;
      |             ^~~~
horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:71:18: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   71 |     return recalc();
      |            ~~~~~~^~
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:76:15: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   76 |  return recalc();
      |         ~~~~~~^~
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:81:15: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   81 |  return recalc();
      |         ~~~~~~^~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 432 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 436 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 392 KB Output is correct
16 Correct 0 ms 344 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 432 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 10 ms 348 KB Output is correct
24 Correct 10 ms 348 KB Output is correct
25 Correct 10 ms 344 KB Output is correct
26 Correct 10 ms 348 KB Output is correct
27 Correct 9 ms 472 KB Output is correct
28 Correct 10 ms 348 KB Output is correct
29 Correct 10 ms 472 KB Output is correct
30 Correct 10 ms 348 KB Output is correct
31 Correct 6 ms 480 KB Output is correct
32 Correct 9 ms 472 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1534 ms 14168 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 432 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 10 ms 348 KB Output is correct
24 Correct 10 ms 492 KB Output is correct
25 Correct 10 ms 348 KB Output is correct
26 Correct 10 ms 488 KB Output is correct
27 Correct 10 ms 344 KB Output is correct
28 Correct 10 ms 488 KB Output is correct
29 Correct 10 ms 348 KB Output is correct
30 Correct 10 ms 348 KB Output is correct
31 Correct 7 ms 344 KB Output is correct
32 Correct 9 ms 344 KB Output is correct
33 Execution timed out 1518 ms 15960 KB Time limit exceeded
34 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 436 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 10 ms 348 KB Output is correct
24 Correct 10 ms 348 KB Output is correct
25 Correct 10 ms 348 KB Output is correct
26 Correct 10 ms 488 KB Output is correct
27 Correct 9 ms 604 KB Output is correct
28 Correct 10 ms 348 KB Output is correct
29 Correct 10 ms 348 KB Output is correct
30 Correct 10 ms 348 KB Output is correct
31 Correct 7 ms 348 KB Output is correct
32 Correct 9 ms 476 KB Output is correct
33 Execution timed out 1534 ms 14164 KB Time limit exceeded
34 Halted 0 ms 0 KB -