# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1014618 | MarwenElarbi | Horses (IOI15_horses) | C++17 | 19 ms | 12320 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "horses.h"
using namespace std;
#define ll long long
#define pb push_back
#define se second
#define fi first
const int MOD=1e9+7;
pair<ll,ll> tab[1005];
int n;
int init(int N, int X[], int Y[]){
n=N;
for (int i = 0; i < N; ++i)
{
tab[i]={X[i],Y[i]};
}
ll cur=0;
ll pos;
for (int i = N-1; i >= 0; --i)
{
if(cur<Y[i]){
pos=i;
cur=Y[i];
}
if(cur<=1e9) cur*=1ll*X[i];
}
ll res=1;
for (int i = 0; i < pos; ++i)
{
res*=1ll*X[i];
res%=MOD;
}
res*=1ll*X[pos]*Y[pos]%MOD;
res%=MOD;
return res;
}
int updateX(int pos, int val){
tab[pos].fi=val;
ll cur=0;
ll ps;
for (int i = n-1; i >= 0; --i)
{
if(cur<tab[i].se){
ps=i;
cur=tab[i].se;
}
if(cur<=1e9) cur*=1ll*tab[i].fi;
}
ll res=1;
for (int i = 0; i < ps; ++i)
{
res*=tab[i].fi;
res%=MOD;
}
res*=1ll*tab[ps].fi*tab[ps].se%MOD;
res%=MOD;
return res;
}
int updateY(int pos, int val) {
tab[pos].se=val;
ll cur=0;
ll ps;
for (int i = n-1; i >= 0; --i)
{
if(cur<tab[i].se){
ps=i;
cur=tab[i].se;
}
if(cur<=1e9) cur*=tab[i].fi;
}
ll res=1;
for (int i = 0; i < ps; ++i)
{
res*=tab[i].fi;
res%=MOD;
}
res*=1ll*tab[ps].fi*tab[ps].se%MOD;
res%=MOD;
return res;
}
/*
int main() {
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
int N; cin>>N;
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++) {
cin>>X[i];
}
for (int i = 0; i < N; i++) {
cin>>Y[i];
}
cout <<init(N,X,Y)<<" ";
int M; cin>>M;
for (int i = 0; i < M; i++) {
int type; cin>>type;
int pos; cin>>pos;
int val; cin>>val;
if (type == 1) {
cout <<updateX(pos,val)<<" ";
} else if (type == 2) {
cout <<updateY(pos,val)<<" ";
}
}
return 0;
}*/
컴파일 시 표준 에러 (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... |