# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1004557 | vjudge1 | Horses (IOI15_horses) | C++17 | 1527 ms | 12192 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define f first
#define s second
#define pb push_back
#define pf push_front
#define pi pair<int,int>
#define vi vector<int>
int n ;
vector<pi> x, y;
const int mod = 1e9+7;
ll init(int N, int X[], int Y[]){
n = N;
x.resize(N);
y.resize(N);
ll ke = 0;
for(int i =0; i < n; i++){
while(X[i]>=mod){
ke++;
X[i]%=mod;
}
x[i] = {ke, X[i]};
ke = 0;
while(Y[i]>=mod){
ke++;
Y[i]%=mod;
}
y[i] = {ke, Y[i]};
}
ll final = 0;
ll have = 1;
ll cnt = 0, left = 0, prev =1;
ll ccnt = 0, cleft= 0, cl=0;
for(int i = 1; i <= n; i++){
ccnt += x[i-1].f;
have = ((have* x[i-1].s));
cleft = 0;
while(have>=mod){
cleft++;
have %=mod;
}
ccnt *= cleft;
ll hold = have*y[i-1].s;
cleft = 0;
while(hold >=mod){
hold%=mod;
cleft++;
}
if((ccnt*y[i-1].f)*cleft> cnt){
cnt = (ccnt*y[i-1].f)*cleft;
left = hold;
}
else if((ccnt*y[i-1].f)*cleft==cnt && hold> left){
cnt = (ccnt*y[i-1].f)*cleft;
left = hold;
}
}
return left;
}
ll updateX(int pos, int val){
int he = 0;
while(val>=mod){
he++;
val%=mod;
}
x[pos]={he,val};
ll final = 0;
ll have = 1;
ll cnt = 0, left = 0, prev =1;
ll ccnt = 0, cleft= 0, cl=0;
for(int i = 1; i <= n; i++){
ccnt += x[i-1].f;
have = ((have* x[i-1].s));
cleft = 0;
while(have>=mod){
cleft++;
have %=mod;
}
ccnt *= cleft;
ll hold = have*y[i-1].s;
cleft = 0;
while(hold >=mod){
hold%=mod;
cleft++;
}
if((ccnt*y[i-1].f)*cleft> cnt){
cnt = (ccnt*y[i-1].f)*cleft;
left = hold;
}
else if((ccnt*y[i-1].f)*cleft==cnt && hold> left){
cnt = (ccnt*y[i-1].f)*cleft;
left = hold;
}
}
return left;
}
ll updateY(int pos, int val){
int he = 0;
while(val>=mod){
he++;
val%=mod;
}
y[pos]={he,val};
ll final = 0;
ll have = 1;
ll cnt = 0, left = 0, prev =1;
ll ccnt = 0, cleft= 0, cl=0;
for(int i = 1; i <= n; i++){
ccnt += x[i-1].f;
have = ((have* x[i-1].s));
cleft = 0;
while(have>=mod){
cleft++;
have %=mod;
}
ccnt *= cleft;
ll hold = have*y[i-1].s;
cleft = 0;
while(hold >=mod){
hold%=mod;
cleft++;
}
if((ccnt*y[i-1].f)*cleft> cnt){
cnt = (ccnt*y[i-1].f)*cleft;
left = hold;
}
else if((ccnt*y[i-1].f)*cleft==cnt && hold> left){
cnt = (ccnt*y[i-1].f)*cleft;
left = hold;
}
}
return left;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |