답안 #488022

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
488022 2021-11-17T12:32:10 Z egekabas 말 (IOI15_horses) C++14
100 / 100
183 ms 66660 KB
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pull;
typedef pair<int, int> pii;
typedef pair<ld, ld> pld;
const ll mod = 1e9+7;
struct node{
    ll y, lef, rig, lefmod, rigmod;
};
node merge(node a, node b){
    node ret;
    if(a.y > min(mod, a.rig*b.lef)*b.y){
        ret.y = a.y;
        ret.lef = a.lef;
        ret.rig = min(mod, min(mod, a.rig*b.lef)*b.rig);
        ret.lefmod = a.lefmod;
        ret.rigmod = a.rigmod*b.lefmod%mod*b.rigmod%mod;
    }
    else{
        ret.y = b.y;
        ret.lef = min(mod, min(mod, a.lef*a.rig)*b.lef);
        ret.rig = b.rig;
        ret.lefmod = a.lefmod*a.rigmod%mod*b.lefmod%mod;
        ret.rigmod = b.rigmod;
    }
    return ret;
}
node seg[2000009];
ll x[500009];
ll y[500009];
void upd(ll v, ll tl, ll tr, ll idx, ll xval, ll yval){
    if(tl == idx && tr == idx){
        seg[v] = {yval, xval, 1, xval, 1};
        return;
    }
    if(idx <= (tl+tr)/2)
        upd(2*v, tl, (tl+tr)/2, idx, xval, yval);
    else
        upd(2*v+1, (tl+tr)/2+1, tr, idx, xval, yval);
    seg[v] = merge(seg[2*v], seg[2*v+1]);    
}
void build(ll v, ll tl, ll tr){
    if(tl == tr){
        seg[v] = {y[tl], x[tl], 1, x[tl], 1};
        return;
    }
    build(2*v, tl, (tl+tr)/2);
    build(2*v+1, (tl+tr)/2+1, tr);
    seg[v] = merge(seg[2*v], seg[2*v+1]);    
}
ll n;
int init(int N, int X[], int Y[]) {
	n = N;
    for(int i = 0; i < N; ++i){
        x[i] = X[i];
        y[i] = Y[i];
    }
    build(1, 0, n-1);
    return seg[1].lefmod*seg[1].y%mod;
}

int updateX(int pos, int val) {	
    x[pos] = val;
    upd(1, 0, n-1, pos, x[pos], y[pos]);
    return seg[1].lefmod*seg[1].y%mod;
}

int updateY(int pos, int val) {
	y[pos] = val;
    upd(1, 0, n-1, pos, x[pos], y[pos]);
    return seg[1].lefmod*seg[1].y%mod;
}

Compilation message

horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:68:34: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   68 |     return seg[1].lefmod*seg[1].y%mod;
      |            ~~~~~~~~~~~~~~~~~~~~~~^~~~
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:74:34: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   74 |     return seg[1].lefmod*seg[1].y%mod;
      |            ~~~~~~~~~~~~~~~~~~~~~~^~~~
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:80:34: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   80 |     return seg[1].lefmod*seg[1].y%mod;
      |            ~~~~~~~~~~~~~~~~~~~~~~^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 0 ms 204 KB Output is correct
20 Correct 0 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 0 ms 204 KB Output is correct
20 Correct 0 ms 204 KB Output is correct
21 Correct 0 ms 204 KB Output is correct
22 Correct 0 ms 208 KB Output is correct
23 Correct 1 ms 336 KB Output is correct
24 Correct 1 ms 336 KB Output is correct
25 Correct 1 ms 464 KB Output is correct
26 Correct 1 ms 464 KB Output is correct
27 Correct 1 ms 336 KB Output is correct
28 Correct 1 ms 336 KB Output is correct
29 Correct 2 ms 336 KB Output is correct
30 Correct 1 ms 336 KB Output is correct
31 Correct 1 ms 336 KB Output is correct
32 Correct 1 ms 336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 90 ms 53976 KB Output is correct
2 Correct 173 ms 66616 KB Output is correct
3 Correct 152 ms 57760 KB Output is correct
4 Correct 183 ms 61668 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 0 ms 204 KB Output is correct
20 Correct 0 ms 204 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 0 ms 208 KB Output is correct
23 Correct 1 ms 336 KB Output is correct
24 Correct 1 ms 336 KB Output is correct
25 Correct 1 ms 448 KB Output is correct
26 Correct 1 ms 464 KB Output is correct
27 Correct 1 ms 336 KB Output is correct
28 Correct 1 ms 336 KB Output is correct
29 Correct 1 ms 336 KB Output is correct
30 Correct 1 ms 336 KB Output is correct
31 Correct 1 ms 336 KB Output is correct
32 Correct 1 ms 336 KB Output is correct
33 Correct 70 ms 57000 KB Output is correct
34 Correct 59 ms 57012 KB Output is correct
35 Correct 75 ms 64056 KB Output is correct
36 Correct 84 ms 63908 KB Output is correct
37 Correct 50 ms 55240 KB Output is correct
38 Correct 51 ms 56184 KB Output is correct
39 Correct 44 ms 55140 KB Output is correct
40 Correct 64 ms 59076 KB Output is correct
41 Correct 44 ms 55192 KB Output is correct
42 Correct 48 ms 55248 KB Output is correct
43 Correct 56 ms 59464 KB Output is correct
44 Correct 56 ms 59408 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 0 ms 204 KB Output is correct
20 Correct 0 ms 204 KB Output is correct
21 Correct 0 ms 204 KB Output is correct
22 Correct 0 ms 208 KB Output is correct
23 Correct 1 ms 336 KB Output is correct
24 Correct 1 ms 336 KB Output is correct
25 Correct 1 ms 464 KB Output is correct
26 Correct 1 ms 464 KB Output is correct
27 Correct 1 ms 336 KB Output is correct
28 Correct 1 ms 336 KB Output is correct
29 Correct 1 ms 336 KB Output is correct
30 Correct 1 ms 336 KB Output is correct
31 Correct 1 ms 336 KB Output is correct
32 Correct 1 ms 336 KB Output is correct
33 Correct 93 ms 57808 KB Output is correct
34 Correct 172 ms 66660 KB Output is correct
35 Correct 139 ms 57800 KB Output is correct
36 Correct 159 ms 61640 KB Output is correct
37 Correct 59 ms 57096 KB Output is correct
38 Correct 64 ms 57148 KB Output is correct
39 Correct 75 ms 64048 KB Output is correct
40 Correct 85 ms 63948 KB Output is correct
41 Correct 53 ms 55240 KB Output is correct
42 Correct 50 ms 56140 KB Output is correct
43 Correct 45 ms 55148 KB Output is correct
44 Correct 58 ms 59072 KB Output is correct
45 Correct 45 ms 55192 KB Output is correct
46 Correct 51 ms 55152 KB Output is correct
47 Correct 55 ms 59392 KB Output is correct
48 Correct 55 ms 59416 KB Output is correct
49 Correct 159 ms 59132 KB Output is correct
50 Correct 151 ms 59244 KB Output is correct
51 Correct 150 ms 65848 KB Output is correct
52 Correct 127 ms 65396 KB Output is correct
53 Correct 140 ms 57472 KB Output is correct
54 Correct 109 ms 58016 KB Output is correct
55 Correct 94 ms 56156 KB Output is correct
56 Correct 116 ms 60868 KB Output is correct
57 Correct 95 ms 56776 KB Output is correct
58 Correct 93 ms 57292 KB Output is correct
59 Correct 57 ms 59372 KB Output is correct