답안 #710530

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
710530 2023-03-15T10:23:58 Z ssense 말 (IOI15_horses) C++14
17 / 100
44 ms 11100 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 > 1000000000)
        {
            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;}
      |                                                                                                                       ~~~~~~~~^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 296 KB Output is correct
3 Correct 1 ms 296 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 296 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 304 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 300 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 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 300 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 304 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 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 296 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 300 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 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 300 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 Incorrect 44 ms 11100 KB Output isn't correct
2 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 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 1 ms 308 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 300 KB Output is correct
9 Correct 1 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 304 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 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 272 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 300 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 296 KB Output is correct
3 Correct 1 ms 300 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 304 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 300 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 304 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 1 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 304 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Incorrect 1 ms 312 KB Output isn't correct
24 Halted 0 ms 0 KB -