Submission #1085332

# Submission time Handle Problem Language Result Execution time Memory
1085332 2024-09-08T03:14:58 Z guagua0407 Horses (IOI15_horses) C++17
34 / 100
1500 ms 16124 KB
#include "horses.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int,int>
#define f first
#define s second
#define all(x) x.begin(),x.end()
#define _ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

int n;
vector<ll> x,y;
const ll inf=1e9;
const ll mod=1e9+7;

int init(int N, int X[], int Y[]) {
    n=N;
    x.resize(n);
    y.resize(n);
    for(int i=0;i<n;i++){
        x[i]=X[i];
        y[i]=Y[i];
    }
    int best=n-1;
    ll cur=y[n-1];
    for(int i=n-1;i>=0;i--){
        if(y[i]>cur){
            best=i;
            cur=y[i];
        }
        if(cur*x[i]>inf) break;
        cur*=x[i];
    }
    ll ans=1;
    for(int i=0;i<=best;i++){
        ans=ans*x[i]%mod;
    }
    ans=ans*y[best]%mod;
	return ans;
}

int updateX(int pos, int val) {
    x[pos]=val;
    int best=n-1;
    ll cur=y[n-1];
    for(int i=n-1;i>=0;i--){
        if(y[i]>cur){
            best=i;
            cur=y[i];
        }
        if(cur*x[i]>inf) break;
        cur*=x[i];
    }
    ll ans=1;
    for(int i=0;i<=best;i++){
        ans=ans*x[i]%mod;
    }
    ans=ans*y[best]%mod;
	return ans;
}

int updateY(int pos, int val) {
    y[pos]=val;
    int best=n-1;
    ll cur=y[n-1];
    for(int i=n-1;i>=0;i--){
        if(y[i]>cur){
            best=i;
            cur=y[i];
        }
        if(cur*x[i]>inf) break;
        cur*=x[i];
    }
    ll ans=1;
    for(int i=0;i<=best;i++){
        ans=ans*x[i]%mod;
    }
    ans=ans*y[best]%mod;
	return ans;
}

Compilation message

horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:39:9: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   39 |  return ans;
      |         ^~~
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:59:9: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   59 |  return ans;
      |         ^~~
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:79:9: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   79 |  return ans;
      |         ^~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 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 1 ms 344 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 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 1 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 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 604 KB Output is correct
5 Correct 1 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 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 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 1 ms 348 KB Output is correct
23 Correct 5 ms 420 KB Output is correct
24 Correct 5 ms 456 KB Output is correct
25 Correct 5 ms 348 KB Output is correct
26 Correct 5 ms 484 KB Output is correct
27 Correct 5 ms 348 KB Output is correct
28 Correct 5 ms 348 KB Output is correct
29 Correct 6 ms 348 KB Output is correct
30 Correct 5 ms 348 KB Output is correct
31 Correct 3 ms 348 KB Output is correct
32 Correct 5 ms 480 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1552 ms 14332 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 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 0 ms 352 KB Output is correct
12 Correct 0 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 5 ms 348 KB Output is correct
24 Correct 5 ms 348 KB Output is correct
25 Correct 5 ms 492 KB Output is correct
26 Correct 5 ms 344 KB Output is correct
27 Correct 5 ms 480 KB Output is correct
28 Correct 5 ms 348 KB Output is correct
29 Correct 6 ms 344 KB Output is correct
30 Correct 6 ms 600 KB Output is correct
31 Correct 3 ms 348 KB Output is correct
32 Correct 4 ms 348 KB Output is correct
33 Execution timed out 1565 ms 16124 KB Time limit exceeded
34 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 600 KB Output is correct
2 Correct 0 ms 344 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 344 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 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 1 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 5 ms 604 KB Output is correct
24 Correct 5 ms 348 KB Output is correct
25 Correct 5 ms 348 KB Output is correct
26 Correct 5 ms 348 KB Output is correct
27 Correct 5 ms 348 KB Output is correct
28 Correct 5 ms 348 KB Output is correct
29 Correct 6 ms 440 KB Output is correct
30 Correct 5 ms 348 KB Output is correct
31 Correct 3 ms 480 KB Output is correct
32 Correct 4 ms 348 KB Output is correct
33 Execution timed out 1594 ms 14248 KB Time limit exceeded
34 Halted 0 ms 0 KB -