답안 #710563

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
710563 2023-03-15T11:08:06 Z ssense 말 (IOI15_horses) C++14
37 / 100
124 ms 20968 KB
#include <bits/stdc++.h>
#include "horses.h"

using namespace std;

#define MOD 1000000007

int ng;
vector<long long> xg;
vector<long long> yg;
long long pref = 1;

long long power(long long n, long long pow, long long m) {if (pow == 0) return 1;if (pow % 2 == 0) {long long x = power(n, pow / 2, m);return (x * x) % m;}else return (power(n, pow - 1, m) * n) % m;}

int init(int n, int* x, int* y)
{
    ng = n;
    for(int i = 0; i < n; i++)
    {
        xg.push_back(x[i]);
        yg.push_back(y[i]);
    }
    for(int i = 0; i < ng-32; i++)
    {
        pref*=xg[i];
        pref%=MOD;
    }
    int stop = 0;
    long long p = 1;
    for(int i = ng-1; i >= 0; i--)
    {
        p*=xg[i];
        if(p > 1000000000)
        {
            stop = i;
            break;
        }
    }
    p = pref;
    for(int i = max(0, ng-32); i <= stop; i++)
    {
        p*=xg[i];
        p%=MOD;
    }
    long long mx = 0;
    long long p2 = 1;
    for(int i = stop; i < ng; i++)
    {
        if(i != stop)
        {
            p2*=xg[i];
        }
        if(mx < p2*yg[i])
        {
            mx = p2*yg[i];
        }
    }
    mx%=MOD;
    return (int)((mx*p)%MOD);
}

int updateX(int pos, int val)
{
    if(pos < ng-32)
    {
        pref*=power(xg[pos], MOD-2, MOD);
        pref%=MOD;
        pref*=val;
        pref%=MOD;
    }
    xg[pos] = val;
    int stop = 0;
    long long p = 1;
    for(int i = ng-1; i >= 0; i--)
    {
        p*=xg[i];
        if(p > 1000000000)
        {
            stop = i;
            break;
        }
    }
    p = pref;
    for(int i = max(0, ng-32); i <= stop; i++)
    {
        p*=xg[i];
        p%=MOD;
    }
    long long mx = 0;
    long long p2 = 1;
    for(int i = stop; i < ng; i++)
    {
        if(i != stop)
        {
            p2*=xg[i];
        }
        if(mx < p2*yg[i])
        {
            mx = p2*yg[i];
        }
    }
    mx%=MOD;
    return (int)((mx*p)%MOD);
}

int updateY(int pos, int val)
{
    yg[pos] = val;
    int stop = 0;
    long long p = 1;
    for(int i = ng-1; i >= 0; i--)
    {
        p*=xg[i];
        if(p > 1000000000)
        {
            stop = i;
            break;
        }
    }
    p = pref;
    for(int i = max(0, ng-32); i <= stop; i++)
    {
        p*=xg[i];
        p%=MOD;
    }
    long long mx = 0;
    long long p2 = 1;
    for(int i = stop; i < ng; i++)
    {
        if(i != stop)
        {
            p2*=xg[i];
        }
        if(mx < p2*yg[i])
        {
            mx = p2*yg[i];
        }
    }
    mx%=MOD;
    return (int)((mx*p)%MOD);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 260 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Incorrect 1 ms 212 KB Output isn't correct
24 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 42 ms 13252 KB Output is correct
2 Correct 124 ms 13300 KB Output is correct
3 Correct 74 ms 16932 KB Output is correct
4 Correct 114 ms 20968 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Incorrect 1 ms 212 KB Output isn't correct
24 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 336 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Incorrect 1 ms 212 KB Output isn't correct
24 Halted 0 ms 0 KB -