Submission #500999

# Submission time Handle Problem Language Result Execution time Memory
500999 2022-01-01T23:45:10 Z AmirElarbi Horses (IOI15_horses) C++14
17 / 100
13 ms 10536 KB
#include <bits/stdc++.h>
#include "horses.h"
#define vi vector<int>
#define ve vector
#define ll long long
#define vf vector<float>
#define vll vector<pair<ll,ll>>
#define ii pair<int,int>
#define vvi vector<vi>
#define vii vector<ii>
#define gii greater<ii>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define INF 1e9
#define eps 1e-7
#define eps1 1e-25
#define optimise ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MAX_A 1e5+5
#define V 450
using namespace std;
const int MOD = 1e9+7;
ll x[1005],y[1005];
ll dp[1005];
int n;
ll srch(int i, ll nb){
	if(i == n) return 0;
	if(dp[i]!=-1)return dp[i];
	return dp[i] = max(srch(i+1,(nb%MOD*x[i]%MOD)%MOD)%MOD, ((nb%MOD*x[i]%MOD)%MOD*y[i])%MOD);
}
int init(int N, int X[], int Y[]) {
	n = N;
	memset(dp,-1,sizeof dp);
	for (int i = 0; i < n; ++i)
	{
		x[i] = X[i];
		y[i] = Y[i];
	}
	return srch(0,1)%MOD;
}

int updateX(int pos, int val) {	
	x[pos] = val;
	memset(dp,-1,sizeof dp);
	return srch(0,1)%MOD;
}

int updateY(int pos, int val) {
	y[pos] = val;
	memset(dp,-1,sizeof dp);
	return srch(0,1)%MOD;
}

Compilation message

horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:40:18: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   40 |  return srch(0,1)%MOD;
      |         ~~~~~~~~~^~~~
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:46:18: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   46 |  return srch(0,1)%MOD;
      |         ~~~~~~~~~^~~~
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:52:18: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   52 |  return srch(0,1)%MOD;
      |         ~~~~~~~~~^~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 296 KB Output is correct
5 Correct 0 ms 300 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 296 KB Output is correct
8 Correct 0 ms 292 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 296 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 0 ms 300 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 0 ms 300 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 1 ms 288 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 0 ms 204 KB Output is correct
20 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 1 ms 292 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 0 ms 296 KB Output is correct
19 Correct 0 ms 204 KB Output is correct
20 Correct 0 ms 204 KB Output is correct
21 Incorrect 0 ms 292 KB Output isn't correct
22 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 13 ms 10536 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 296 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 296 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 1 ms 300 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 0 ms 204 KB Output is correct
20 Correct 0 ms 204 KB Output is correct
21 Incorrect 0 ms 204 KB Output isn't correct
22 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 284 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 292 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 296 KB Output is correct
7 Correct 1 ms 276 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 288 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 0 ms 292 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 0 ms 300 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 0 ms 284 KB Output is correct
20 Correct 0 ms 204 KB Output is correct
21 Incorrect 0 ms 292 KB Output isn't correct
22 Halted 0 ms 0 KB -