답안 #408755

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
408755 2021-05-19T15:21:38 Z MDario 말 (IOI15_horses) C++11
100 / 100
182 ms 46300 KB
#include "horses.h"
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
const ll mod=1e9+7;
ll a[500001], b[500001];
pair<pair<ll, ll>, pair<ll, ll>> st[2000001];
void f(ll xf){
    if(st[xf*2+1].S.F==1){
        st[xf]={{(((st[xf*2].F.F*st[xf*2].S.S)%mod)*st[xf*2+1].F.F)%mod, st[xf*2+1].F.S}, {1, st[xf*2+1].S.S}};
    }
    else{
        if(st[xf*2].F.S<st[xf*2].S.S*st[xf*2+1].F.F*st[xf*2+1].F.S){
            st[xf]={{(((st[xf*2].F.F*st[xf*2].S.S)%mod)*st[xf*2+1].F.F)%mod, st[xf*2+1].F.S}, {(st[xf*2].S.F||(st[xf*2].S.S*st[xf*2+1].F.F*st[xf*2+1].F.S*st[xf*2].F.F)>=1e9), st[xf*2+1].S.S}};
        }
        else{
            st[xf]=st[xf*2];
            st[xf].S.S*=st[xf*2+1].S.S*st[xf*2+1].F.F;
        }
    }
    return ;
}
void build(ll xf, ll lf, ll rf){
    if(lf==rf){
        st[xf]={{a[lf], b[lf]}, {(a[lf]*b[lf]>=1e9), 1}};
        return;
    }
    build(xf*2, lf, (lf+rf)/2);
    build(xf*2+1, (lf+rf)/2+1, rf);
    f(xf);
    return ;
}
ll n;
void update(ll xf, ll lf, ll rf, ll of){
    if(rf<of||lf>of)return;
    if(lf==rf){
        st[xf]={{a[lf], b[lf]}, {(a[lf]*b[lf]>=1e9), 1}};
        return;
    }
    update(xf*2, lf, (lf+rf)/2, of);
    update(xf*2+1, (lf+rf)/2+1, rf, of);
    f(xf);
    return ;
}
int init(int N, int X[], int Y[]) {
    n=N;
    for(int i=0; i<N; i++){
        a[i+1]=X[i];
        b[i+1]=Y[i];
    }
    build(1, 1, N);
	return (st[1].F.F*st[1].F.S)%mod;
}

int updateX(int pos, int val) {
    a[pos+1]=val;
    update(1, 1, n, pos+1);
	return (st[1].F.F*st[1].F.S)%mod;
}

int updateY(int pos, int val) {
    b[pos+1]=val;
    update(1, 1, n, pos+1);
	return (st[1].F.F*st[1].F.S)%mod;
}

Compilation message

horses.cpp: In function 'void f(ll)':
horses.cpp:16:154: warning: conversion from 'long long int' to 'double' may change value [-Wconversion]
   16 |             st[xf]={{(((st[xf*2].F.F*st[xf*2].S.S)%mod)*st[xf*2+1].F.F)%mod, st[xf*2+1].F.S}, {(st[xf*2].S.F||(st[xf*2].S.S*st[xf*2+1].F.F*st[xf*2+1].F.S*st[xf*2].F.F)>=1e9), st[xf*2+1].S.S}};
      |                                                                                                               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
horses.cpp: In function 'void build(ll, ll, ll)':
horses.cpp:27:40: warning: conversion from 'll' {aka 'long long int'} to 'double' may change value [-Wconversion]
   27 |         st[xf]={{a[lf], b[lf]}, {(a[lf]*b[lf]>=1e9), 1}};
      |                                   ~~~~~^~~~~~
horses.cpp: In function 'void update(ll, ll, ll, ll)':
horses.cpp:39:40: warning: conversion from 'll' {aka 'long long int'} to 'double' may change value [-Wconversion]
   39 |         st[xf]={{a[lf], b[lf]}, {(a[lf]*b[lf]>=1e9), 1}};
      |                                   ~~~~~^~~~~~
horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:54:30: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   54 |  return (st[1].F.F*st[1].F.S)%mod;
      |         ~~~~~~~~~~~~~~~~~~~~~^~~~
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:60:30: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   60 |  return (st[1].F.F*st[1].F.S)%mod;
      |         ~~~~~~~~~~~~~~~~~~~~~^~~~
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:66:30: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   66 |  return (st[1].F.F*st[1].F.S)%mod;
      |         ~~~~~~~~~~~~~~~~~~~~~^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 296 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 304 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 304 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 300 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 300 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 308 KB Output is correct
23 Correct 1 ms 332 KB Output is correct
24 Correct 1 ms 332 KB Output is correct
25 Correct 1 ms 332 KB Output is correct
26 Correct 1 ms 332 KB Output is correct
27 Correct 1 ms 332 KB Output is correct
28 Correct 1 ms 316 KB Output is correct
29 Correct 1 ms 316 KB Output is correct
30 Correct 1 ms 332 KB Output is correct
31 Correct 1 ms 332 KB Output is correct
32 Correct 1 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 85 ms 45764 KB Output is correct
2 Correct 167 ms 46036 KB Output is correct
3 Correct 143 ms 46048 KB Output is correct
4 Correct 151 ms 46020 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 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 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 304 KB Output is correct
16 Correct 1 ms 304 KB Output is correct
17 Correct 1 ms 304 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 304 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 1 ms 332 KB Output is correct
24 Correct 1 ms 316 KB Output is correct
25 Correct 1 ms 448 KB Output is correct
26 Correct 1 ms 448 KB Output is correct
27 Correct 1 ms 332 KB Output is correct
28 Correct 1 ms 332 KB Output is correct
29 Correct 1 ms 332 KB Output is correct
30 Correct 1 ms 312 KB Output is correct
31 Correct 1 ms 332 KB Output is correct
32 Correct 1 ms 332 KB Output is correct
33 Correct 58 ms 45132 KB Output is correct
34 Correct 58 ms 45156 KB Output is correct
35 Correct 81 ms 45144 KB Output is correct
36 Correct 76 ms 45132 KB Output is correct
37 Correct 45 ms 45208 KB Output is correct
38 Correct 48 ms 45164 KB Output is correct
39 Correct 41 ms 45068 KB Output is correct
40 Correct 58 ms 45168 KB Output is correct
41 Correct 39 ms 45124 KB Output is correct
42 Correct 39 ms 45220 KB Output is correct
43 Correct 53 ms 45124 KB Output is correct
44 Correct 53 ms 45028 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 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 1 ms 284 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 304 KB Output is correct
21 Correct 1 ms 300 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 2 ms 332 KB Output is correct
24 Correct 1 ms 332 KB Output is correct
25 Correct 1 ms 440 KB Output is correct
26 Correct 1 ms 332 KB Output is correct
27 Correct 1 ms 332 KB Output is correct
28 Correct 1 ms 332 KB Output is correct
29 Correct 1 ms 332 KB Output is correct
30 Correct 1 ms 332 KB Output is correct
31 Correct 1 ms 332 KB Output is correct
32 Correct 1 ms 332 KB Output is correct
33 Correct 87 ms 46300 KB Output is correct
34 Correct 164 ms 46020 KB Output is correct
35 Correct 137 ms 46056 KB Output is correct
36 Correct 152 ms 46192 KB Output is correct
37 Correct 59 ms 45120 KB Output is correct
38 Correct 58 ms 45144 KB Output is correct
39 Correct 74 ms 45172 KB Output is correct
40 Correct 76 ms 45124 KB Output is correct
41 Correct 45 ms 45124 KB Output is correct
42 Correct 49 ms 45104 KB Output is correct
43 Correct 47 ms 45124 KB Output is correct
44 Correct 57 ms 45164 KB Output is correct
45 Correct 42 ms 45192 KB Output is correct
46 Correct 39 ms 45188 KB Output is correct
47 Correct 53 ms 45056 KB Output is correct
48 Correct 52 ms 45024 KB Output is correct
49 Correct 182 ms 46072 KB Output is correct
50 Correct 158 ms 46148 KB Output is correct
51 Correct 120 ms 46152 KB Output is correct
52 Correct 125 ms 46120 KB Output is correct
53 Correct 139 ms 46020 KB Output is correct
54 Correct 99 ms 46024 KB Output is correct
55 Correct 84 ms 45232 KB Output is correct
56 Correct 123 ms 46052 KB Output is correct
57 Correct 82 ms 46068 KB Output is correct
58 Correct 83 ms 46136 KB Output is correct
59 Correct 53 ms 45124 KB Output is correct