답안 #709937

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
709937 2023-03-14T21:29:20 Z ssense 말 (IOI15_horses) C++17
17 / 100
41 ms 9328 KB
#include <bits/stdc++.h>
#include "horses.h"

using namespace std;

#define MOD 1000000007

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

int power(int n, int pow, int 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*=x[i];
        if(p > 1e9)
        {
            stop = i+1;
            break;
        }
    }
    p = pref;
    for(int i = max(0, ng-32); i < stop; i++)
    {
        p*=x[i];
        p%=MOD;
    }
    long long mx = 0;
    long long p2 = 1;
    for(int i = stop; i < ng; i++)
    {
        p2*=x[i];
        if(mx < p2*yg[i])
        {
            mx = p2*yg[i];
        }
    }
    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+1;
            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++)
    {
        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+1;
            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++)
    {
        p2*=xg[i];
        if(mx < p2*yg[i])
        {
            mx = p2*yg[i];
        }
    }
    mx%=MOD;
    return (int)((mx*p)%MOD);
}

Compilation message

horses.cpp: In function 'int power(int, int, int)':
horses.cpp:13:127: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   13 | int power(int n, int pow, int 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;}
      |                                                                                                                       ~~~~~~~~^~~
horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:33:12: warning: conversion from 'long long int' to 'double' may change value [-Wconversion]
   33 |         if(p > 1e9)
      |            ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 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 1 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 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 0 ms 212 KB Output is correct
20 Correct 1 ms 212 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 0 ms 212 KB Output is correct
5 Correct 0 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 1 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 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 1 ms 212 KB Output is correct
17 Correct 1 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 336 KB Output isn't correct
24 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 41 ms 9328 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 292 KB Output is correct
4 Correct 0 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 1 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 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 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Incorrect 1 ms 340 KB Output isn't correct
24 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 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 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 216 KB Output is correct
18 Correct 0 ms 220 KB Output is correct
19 Correct 1 ms 216 KB Output is correct
20 Correct 0 ms 220 KB Output is correct
21 Correct 0 ms 220 KB Output is correct
22 Correct 1 ms 220 KB Output is correct
23 Incorrect 1 ms 340 KB Output isn't correct
24 Halted 0 ms 0 KB -