Submission #231807

#TimeUsernameProblemLanguageResultExecution timeMemory
231807MasterdanHorses (IOI15_horses)C++14
17 / 100
1577 ms22628 KiB
#include "horses.h"
#include <bits/stdc++.h>
#define MIN -1
#define MAX 1000000007
#define all(a)  a.begin (), a.end ()
#define pb  push_back
#define mp  make_pair
#define F  first
#define S  second
#define mem(a, c)  memset(a, c, sizeof(a))
using namespace  std;
typedef vector <int> vi;
typedef long long int ll;
typedef pair <int, int>  ii;
typedef vector <ll> vll;
int n;
ll lol=MAX;
vll vx, vy;
int solve(vll vx, vll vy, int n){
    ll acum=1;
    ll maxi=MIN;
    for(int i=0;i<n;i++){
        acum*=vx[i];
        acum=acum%lol;
        ll aux=(acum*vy[i])%lol;
        maxi=max(maxi, aux);
    }
    return int(maxi);
}
int init(int n, int x[], int y[]) {
    for(int i=0;i<n;i++){
        vx.pb(ll(x[i]));
        vy.pb(ll(y[i]));
    }
    return solve(vx, vy, n);
}

int updateX(int pos, int val) {
	vx[pos]=ll(val);
	return solve(vx, vy, n);
}

int updateY(int pos, int val) {
	vy[pos]=ll(val);
	return solve(vx, vy, n);
}
/*
static char _buffer[1024];
static int _currentChar = 0;
static int _charsNumber = 0;
static FILE *_inputFile, *_outputFile;

static inline int _read() {
    if (_charsNumber < 0) {
        exit(1);
    }
    if (!_charsNumber || _currentChar == _charsNumber) {
        _charsNumber = (int)fread(_buffer, sizeof(_buffer[0]), sizeof(_buffer), _inputFile);
        _currentChar = 0;
    }
    if (_charsNumber <= 0) {
        return -1;
    }
    return _buffer[_currentChar++];
}

static inline int _readInt() {
    int c, x, s;
    c = _read();
    while (c <= 32) c = _read();
    x = 0;
    s = 1;
    if (c == '-') {
        s = -1;
        c = _read();
    }
    while (c > 32) {
        x *= 10;
        x += c - '0';
        c = _read();
    }
    if (s < 0) x = -x;
    return x;
}


int main() {
	_inputFile = fopen("horses.in", "rb");
	_outputFile = fopen("horses.out", "w");

	int N; N = _readInt();

	int *X = (int*)malloc(sizeof(int)*(unsigned int)N);
	int *Y = (int*)malloc(sizeof(int)*(unsigned int)N);

	for (int i = 0; i < N; i++) {
		X[i] = _readInt();
	}

	for (int i = 0; i < N; i++) {
		Y[i] = _readInt();
	}
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        int x;
        cin>>x;
        X[i]=x;
    }
    for(int i=0;i<n;i++){
        int x;
        cin>>x;
        Y[i]=x;
    }
	fprintf(_outputFile,"%d\n",init(n,X,Y));
    cout<<init(n, X, Y)<<endl;
	int M; M = _readInt();

	for (int i = 0; i < M; i++) {
		int type; type = _readInt();
		int pos; pos = _readInt();
		int val; val = _readInt();

		if (type == 1) {
			fprintf(_outputFile,"%d\n",updateX(pos,val));
		} else if (type == 2) {
			fprintf(_outputFile,"%d\n",updateY(pos,val));
		}
	}

	return 0;
}

*/

Compilation message (stderr)

horses.cpp: In function 'int solve(vll, vll, int)':
horses.cpp:19:32: warning: declaration of 'n' shadows a global declaration [-Wshadow]
 int solve(vll vx, vll vy, int n){
                                ^
horses.cpp:16:5: note: shadowed declaration is here
 int n;
     ^
horses.cpp:19:32: warning: declaration of 'vy' shadows a global declaration [-Wshadow]
 int solve(vll vx, vll vy, int n){
                                ^
horses.cpp:18:9: note: shadowed declaration is here
 vll vx, vy;
         ^~
horses.cpp:19:32: warning: declaration of 'vx' shadows a global declaration [-Wshadow]
 int solve(vll vx, vll vy, int n){
                                ^
horses.cpp:18:5: note: shadowed declaration is here
 vll vx, vy;
     ^~
horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:30:33: warning: declaration of 'n' shadows a global declaration [-Wshadow]
 int init(int n, int x[], int y[]) {
                                 ^
horses.cpp:16:5: note: shadowed declaration is here
 int n;
     ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...