Submission #203427

#TimeUsernameProblemLanguageResultExecution timeMemory
203427mohammadHorses (IOI15_horses)C++14
17 / 100
1587 ms12280 KiB
/*
░░░░██████████████████
░░▄███████▀▀▀▀▀▀███████▄
░▐████▀▒mohammad▒▀██████▄
░███▀▒▒▒▒alaa▒▒▒▒▒▒▀█████
░▐██▒▒▒alwrawrah▒▒▒▒▒████▌
░▐█▌▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒████▌
░░█▒▄▀▀▀▀▀▄▒▒▄▀▀▀▀▀▄▒▐███▌
░░░▐░░░▄▄░░▌▐░░░▄▄░░▌▐███▌
░▄▀▌░░░▀▀░░▌▐░░░▀▀░░▌▒▀▒█▌
░▌▒▀▄░░░░▄▀▒▒▀▄░░░▄▀▒▒▄▀▒▌
░▀▄▐▒▀▀▀▀▒▒▒▒▒▒▀▀▀▒▒▒▒▒▒█
░░░▀▌▒▄██▄▄▄▄████▄▒▒▒▒█▀
░░░░▄██████████████▒▒▐▌
░░░▀███▀▀████▀█████▀▒▌
░░░░░▌▒▒▒▄▒▒▒▄▒▒▒▒▒▒▐
░░░░░▌▒▒▒▒▀▀▀▒▒▒▒▒▒▒▐
*/
 
#include<bits/stdc++.h>
#include "horses.h"
using namespace std;
 
typedef long long ll ;
const ll oo = 1e13 ;
const double PI = acos(-1) ;
const ll M = 1e9 + 7  ;

ll x[500010] , y[500010] , n , co = 0 , cur = 0;

ll mod(ll x , ll m){
	while(x >= m) co++ , x -= m;
	return x ;
}
ll mod1(ll x , ll m){
	cur = 0;
	while(x >= m) cur++ , x -= m;
	return x ;
}


int init(int N, int X[], int Y[]){
	n = N;
	for(int i = 0 ; i < N ; ++i) x[i] = X[i] , y[i] = Y[i];
	ll x = 1 , ans = 0 , c1 = 0;
	for(int i = 0 ; i < N ; ++i){
		x = mod(x * X[i] , M);
		ll an = mod1(x * y[i] , M);
		if((c1 == co + cur && ans < an) || (co + cur > c1))
			ans = an , c1 = co + cur;
	}
	return ans;
}

int updateX(int pos, int val){	
	x[pos] = val;
	co = 0;
	ll x1 = 1 , ans = 0 , c1 = 0;
	for(int i = 0 ; i < n ; ++i){
		x1 = mod(x1 * x[i] , M);
		ll an = mod1(x1 * y[i] , M);
		if((c1 == co + cur && ans < an) || (co + cur > c1))
			ans = an , c1 = co + cur;
	}
	return ans;
}

int updateY(int pos, int val){
	y[pos] = val;
	co = 0;
	ll x1 = 1 , ans = 0 , c1 = 0;
	for(int i = 0 ; i < n ; ++i){
		x1 = mod(x1 * x[i] , M);
		ll an = mod1(x1 * y[i] , M);
		if((c1 == co + cur && ans < an) || (co + cur > c1))
			ans = an , c1 = co + cur;
	}
	return ans;
}

Compilation message (stderr)

horses.cpp: In function 'll mod(ll, ll)':
horses.cpp:31:19: warning: declaration of 'x' shadows a global declaration [-Wshadow]
 ll mod(ll x , ll m){
                   ^
horses.cpp:29:4: note: shadowed declaration is here
 ll x[500010] , y[500010] , n , co = 0 , cur = 0;
    ^
horses.cpp: In function 'll mod1(ll, ll)':
horses.cpp:35:20: warning: declaration of 'x' shadows a global declaration [-Wshadow]
 ll mod1(ll x , ll m){
                    ^
horses.cpp:29:4: note: shadowed declaration is here
 ll x[500010] , y[500010] , n , co = 0 , cur = 0;
    ^
horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:45:5: warning: declaration of 'x' shadows a global declaration [-Wshadow]
  ll x = 1 , ans = 0 , c1 = 0;
     ^
horses.cpp:29:4: note: shadowed declaration is here
 ll x[500010] , y[500010] , n , co = 0 , cur = 0;
    ^
horses.cpp:52:9: warning: conversion to 'int' from 'll {aka long long int}' may alter its value [-Wconversion]
  return ans;
         ^~~
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:65:9: warning: conversion to 'int' from 'll {aka long long int}' may alter its value [-Wconversion]
  return ans;
         ^~~
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:78:9: warning: conversion to 'int' from 'll {aka long long int}' may alter its value [-Wconversion]
  return ans;
         ^~~
#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...