답안 #1086293

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1086293 2024-09-10T04:15:42 Z RiverFlow 말 (IOI15_horses) C++14
34 / 100
1500 ms 12108 KB
#include "horses.h"

#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for(int i = (a); i <= (b); ++i)
#define FOD(i, b, a) for(int i = (b); i >= (a); --i)


const int N = (int)5e5 + 7;

const int mod = (int)1e9 + 7;

int add(int a, int b) { return a + b < mod ? a + b : a + b - mod; }
int sub(int a, int b) { return a >= b ? a - b : a - b + mod; }
int mul(int a, int b) { return 1LL * a * b % mod; }

int n, x[N], y[N];

#define nl "\n"
#define ll long long

const ll LIM = (int)1e10;

int fx() {
    ll mx = 0;
    int ans = 0;
    FOD(i, n - 1, 0) {
        if (y[i] >= mx) {
            ans = i;
        }
        mx = max(mx, (ll)y[i]);
        mx = min(LIM, mx * x[i]);
    }
    return ans;
}

int init(int N, int X[], int Y[]) {
    n = N;

    FOR(i, 0, n - 1) x[i] = X[i], y[i] = Y[i];

    int px = fx(), ans = 1;
    FOR(i, 0, px) ans = mul(ans, x[i]);

    return mul(ans, y[px]);
}

int updateX(int pos, int val) {
    x[pos] = val;
    int px = fx(), ans = 1;
    FOR(i, 0, px) ans = mul(ans, x[i]);

    return mul(ans, y[px]);
}

int updateY(int pos, int val) {
    y[pos] = val;
    int px = fx(), ans = 1;
    FOR(i, 0, px) ans = mul(ans, x[i]);

    return mul(ans, y[px]);
}


Compilation message

horses.cpp: In function 'int mul(int, int)':
horses.cpp:17:44: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   17 | int mul(int a, int b) { return 1LL * a * b % mod; }
      |                                ~~~~~~~~~~~~^~~~~
horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:39:14: warning: declaration of 'N' shadows a global declaration [-Wshadow]
   39 | int init(int N, int X[], int Y[]) {
      |          ~~~~^
horses.cpp:11:11: note: shadowed declaration is here
   11 | const int N = (int)5e5 + 7;
      |           ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 452 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 396 KB Output is correct
20 Correct 1 ms 444 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 452 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 344 KB Output is correct
22 Correct 0 ms 604 KB Output is correct
23 Correct 7 ms 348 KB Output is correct
24 Correct 7 ms 348 KB Output is correct
25 Correct 7 ms 484 KB Output is correct
26 Correct 7 ms 348 KB Output is correct
27 Correct 7 ms 348 KB Output is correct
28 Correct 7 ms 348 KB Output is correct
29 Correct 6 ms 484 KB Output is correct
30 Correct 6 ms 496 KB Output is correct
31 Correct 3 ms 348 KB Output is correct
32 Correct 5 ms 484 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1534 ms 10416 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 536 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 600 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 7 ms 348 KB Output is correct
24 Correct 7 ms 344 KB Output is correct
25 Correct 7 ms 500 KB Output is correct
26 Correct 7 ms 348 KB Output is correct
27 Correct 7 ms 484 KB Output is correct
28 Correct 7 ms 344 KB Output is correct
29 Correct 5 ms 348 KB Output is correct
30 Correct 6 ms 348 KB Output is correct
31 Correct 3 ms 348 KB Output is correct
32 Correct 4 ms 348 KB Output is correct
33 Execution timed out 1586 ms 12108 KB Time limit exceeded
34 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 344 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 7 ms 344 KB Output is correct
24 Correct 7 ms 488 KB Output is correct
25 Correct 7 ms 456 KB Output is correct
26 Correct 7 ms 348 KB Output is correct
27 Correct 7 ms 492 KB Output is correct
28 Correct 7 ms 348 KB Output is correct
29 Correct 5 ms 348 KB Output is correct
30 Correct 6 ms 396 KB Output is correct
31 Correct 3 ms 344 KB Output is correct
32 Correct 5 ms 348 KB Output is correct
33 Execution timed out 1587 ms 10424 KB Time limit exceeded
34 Halted 0 ms 0 KB -