Submission #298953

# Submission time Handle Problem Language Result Execution time Memory
298953 2020-09-14T11:11:52 Z Azimjon Horses (IOI15_horses) C++17
17 / 100
1500 ms 14420 KB
#include "horses.h"

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;

const ll INF = 1e18;
const ll mod = 1000000007ll;

vll x, y;
int n;

int init(int N, int X[], int Y[]) {
	n = N;
	for (int i = 0; i < n; i++) {
		x.push_back(X[i]);
		y.push_back(Y[i]);
	}


	pll h = {0, 1};
	pll jv = {-INF, -INF};
	for (int i = 0; i < N; i++) {
		h.second *= x[i];
		h.first += h.second / mod;
		h.second %= mod;

		pll t = h;

		t.second *= y[i];
		t.first += t.second / mod;
		t.second %= mod;

		jv = max(t, jv);
	}

	return jv.second;
}

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

	pll h = {0, 1};
	pll jv = {-INF, -INF};
	for (int i = 0; i < n; i++) {
		h.second *= x[i];
		h.first += h.second / mod;
		h.second %= mod;

		pll t = h;

		t.second *= y[i];
		t.first += t.second / mod;
		t.second %= mod;

		jv = max(t, jv);
	}

	return jv.second;
}

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

	pll h = {0, 1};
	pll jv = {-INF, -INF};
	for (int i = 0; i < n; i++) {
		h.second *= x[i];
		h.first += h.second / mod;
		h.second %= mod;

		pll t = h;

		t.second *= y[i];
		t.first += t.second / mod;
		t.second %= mod;

		jv = max(t, jv);
	}

	return jv.second;
}

Compilation message

horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:41:12: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   41 |  return jv.second;
      |         ~~~^~~~~~
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:63:12: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   63 |  return jv.second;
      |         ~~~^~~~~~
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:85:12: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   85 |  return jv.second;
      |         ~~~^~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
6 Correct 1 ms 256 KB Output is correct
7 Correct 1 ms 360 KB Output is correct
8 Correct 1 ms 256 KB Output is correct
9 Correct 1 ms 256 KB Output is correct
10 Correct 1 ms 256 KB Output is correct
11 Correct 1 ms 256 KB Output is correct
12 Correct 1 ms 256 KB Output is correct
13 Correct 1 ms 256 KB Output is correct
14 Correct 0 ms 256 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 1 ms 256 KB Output is correct
18 Correct 1 ms 256 KB Output is correct
19 Correct 0 ms 256 KB Output is correct
20 Correct 0 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
6 Correct 1 ms 256 KB Output is correct
7 Correct 1 ms 256 KB Output is correct
8 Correct 1 ms 256 KB Output is correct
9 Correct 1 ms 256 KB Output is correct
10 Correct 1 ms 256 KB Output is correct
11 Correct 0 ms 256 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 0 ms 256 KB Output is correct
14 Correct 1 ms 256 KB Output is correct
15 Correct 0 ms 256 KB Output is correct
16 Correct 1 ms 256 KB Output is correct
17 Correct 0 ms 256 KB Output is correct
18 Correct 0 ms 256 KB Output is correct
19 Correct 1 ms 256 KB Output is correct
20 Correct 1 ms 256 KB Output is correct
21 Correct 1 ms 256 KB Output is correct
22 Correct 1 ms 416 KB Output is correct
23 Incorrect 8 ms 384 KB Output isn't correct
24 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1579 ms 14420 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 256 KB Output is correct
7 Correct 1 ms 256 KB Output is correct
8 Correct 1 ms 256 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 256 KB Output is correct
11 Correct 0 ms 256 KB Output is correct
12 Correct 0 ms 256 KB Output is correct
13 Correct 1 ms 256 KB Output is correct
14 Correct 0 ms 256 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 1 ms 256 KB Output is correct
17 Correct 0 ms 256 KB Output is correct
18 Correct 0 ms 256 KB Output is correct
19 Correct 0 ms 256 KB Output is correct
20 Correct 1 ms 256 KB Output is correct
21 Correct 1 ms 256 KB Output is correct
22 Correct 1 ms 256 KB Output is correct
23 Incorrect 8 ms 384 KB Output isn't correct
24 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
6 Correct 1 ms 256 KB Output is correct
7 Correct 1 ms 372 KB Output is correct
8 Correct 1 ms 256 KB Output is correct
9 Correct 1 ms 256 KB Output is correct
10 Correct 1 ms 256 KB Output is correct
11 Correct 1 ms 256 KB Output is correct
12 Correct 1 ms 256 KB Output is correct
13 Correct 0 ms 256 KB Output is correct
14 Correct 1 ms 256 KB Output is correct
15 Correct 0 ms 256 KB Output is correct
16 Correct 1 ms 256 KB Output is correct
17 Correct 1 ms 256 KB Output is correct
18 Correct 1 ms 256 KB Output is correct
19 Correct 1 ms 256 KB Output is correct
20 Correct 1 ms 256 KB Output is correct
21 Correct 1 ms 256 KB Output is correct
22 Correct 1 ms 256 KB Output is correct
23 Incorrect 9 ms 384 KB Output isn't correct
24 Halted 0 ms 0 KB -