답안 #1085331

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1085331 2024-09-08T03:12:21 Z guagua0407 말 (IOI15_horses) C++17
0 / 100
1500 ms 10228 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<int> 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(cur*x[i]>inf) break;
        cur*=x[i];
        if(y[i]>cur){
            best=i;
            cur=y[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(cur*x[i]>inf) break;
        cur*=x[i];
        if(y[i]>cur){
            best=i;
            cur=y[i];
        }
    }
    ll ans=1;
    for(int i=0;i<=best;i++){
        ans=ans*x[i]%mod;
    }
    ans=ans*y[best]%mod;
	return ans;
	return 0;
}

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(cur*x[i]>inf) break;
        cur*=x[i];
        if(y[i]>cur){
            best=i;
            cur=y[i];
        }
    }
    ll ans=1;
    for(int i=0;i<=best;i++){
        ans=ans*x[i]%mod;
    }
    ans=ans*y[best]%mod;
	return ans;
	return 0;
}

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:80:9: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   80 |  return ans;
      |         ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1555 ms 10228 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -