Submission #834051

# Submission time Handle Problem Language Result Execution time Memory
834051 2023-08-22T10:22:56 Z Ellinor Horses (IOI15_horses) C++14
Compilation error
0 ms 0 KB
//#include<bits/stdc++.h>
#include <iostream>
#include <vector>
#include <queue>
#include <string>
#include <cmath>
#include <cstdlib>
#include <set>
#include <iomanip>
#include <limits>
#include <map>
#include <assert.h>
#include <algorithm>
#include <list>
#include <iterator>
#include <fstream>
#include <random>
#include <unordered_map>
#include <array>
using namespace std;

#define rep(i,a,b) for (int i = (a); i < b; i++)
#define pb push_back
#define all(x) x.begin(), x.end()
typedef long long ll;
typedef pair<int, int> pii;

ll MOD = 1e9 + 7; // !?

// fast

#include "horses.h" // !

int n;
vector<ll> x, y;

int init(int N, int X[], int Y[]) 
{
    n = N;
    x.assign(N, 0);
    y.assign(N, 0);
    rep(i,0,N) {
        x[i] = X[i];
        y[i] = Y[i];
    }

    ll ans = 0;
    ll horses = 1;
    rep(i,0,N) {
        horses *= x[i];
        ans = max(ans, horses * y[i]);
    }

	return ans;
}

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

    ll ans = 0;
    ll horses = 1;
    rep(i,0,N) {
        horses *= x[i];
        ans = max(ans, horses * y[i]);
    }

	return ans;
}

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

    ll ans = 0;
    ll horses = 1;
    rep(i,0,N) {
        horses *= x[i];
        ans = max(ans, horses * y[i]);
    }

	return ans;
}

// 17p, M = 0

Compilation message

horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:54:9: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   54 |  return ans;
      |         ^~~
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:63:13: error: 'N' was not declared in this scope
   63 |     rep(i,0,N) {
      |             ^
horses.cpp:22:42: note: in definition of macro 'rep'
   22 | #define rep(i,a,b) for (int i = (a); i < b; i++)
      |                                          ^
horses.cpp:68:9: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   68 |  return ans;
      |         ^~~
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:77:13: error: 'N' was not declared in this scope
   77 |     rep(i,0,N) {
      |             ^
horses.cpp:22:42: note: in definition of macro 'rep'
   22 | #define rep(i,a,b) for (int i = (a); i < b; i++)
      |                                          ^
horses.cpp:82:9: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   82 |  return ans;
      |         ^~~