답안 #921633

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
921633 2024-02-04T08:35:05 Z coding_snorlax 말 (IOI15_horses) C++14
컴파일 오류
0 ms 0 KB
#include "horses.h"
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int init(int N, int X[], int Y[]) {
    ll answer = 1,tmp=1,i=-1;
    for(int I=N-1;I>=0;I--){
        if(tmp*X[i]>1000000000) {i=I;break;}
        tmp *= X[i];
    }
    if(i==-1) i=0;
    int place = i;
    ll Max=1,tmp2=1;
    for(int j=i;j<N;j++){
        tmp2*=X[j];
        tmp2*=Y[j];
        if(tmp2>Max){
            Max = tmp2;
            place = j;
        }
        tmp2/=Y[j];
    }
    for(int j=0;j<=place;j++){
        answer*=X[j];
        answer %= (1000000007);
    }
    answer*=Y[place];
    return answer % (1000000007);
}
 
int updateX(int pos, int val) {
    X[pos]=val;
    return init(N,X,Y);
}
 
int updateY(int pos, int val) {
    Y[pos]=val;
    return init(N,X,Y);
}

Compilation message

horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:12:17: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   12 |     int place = i;
      |                 ^
horses.cpp:14:15: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   14 |     for(int j=i;j<N;j++){
      |               ^
horses.cpp:28:19: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   28 |     return answer % (1000000007);
      |            ~~~~~~~^~~~~~~~~~~~~~
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:32:5: error: 'X' was not declared in this scope
   32 |     X[pos]=val;
      |     ^
horses.cpp:33:17: error: 'N' was not declared in this scope
   33 |     return init(N,X,Y);
      |                 ^
horses.cpp:33:21: error: 'Y' was not declared in this scope
   33 |     return init(N,X,Y);
      |                     ^
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:37:5: error: 'Y' was not declared in this scope
   37 |     Y[pos]=val;
      |     ^
horses.cpp:38:17: error: 'N' was not declared in this scope
   38 |     return init(N,X,Y);
      |                 ^
horses.cpp:38:19: error: 'X' was not declared in this scope
   38 |     return init(N,X,Y);
      |                   ^