답안 #1035204

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1035204 2024-07-26T06:33:31 Z Warinchai 말 (IOI15_horses) C++14
100 / 100
153 ms 119636 KB
#include "horses.h"
#include<bits/stdc++.h>
using namespace std;
long long md=1e9+7;
long long inf=1e9+1;
long long y[500005];
long long x[500005];
int n;
struct node{
    long long y,rall,pre,suf,ans,all;
    node(long long _y=0,long long _rall=0,long long _pre=0,long long _suf=0,long long _ans=0,long long _all=0){
        y=_y,rall=_rall,pre=_pre,suf=_suf,ans=_ans,all=_all;
    }
    friend node operator+(node a,node b){
        node c;
        c.rall=(a.rall*b.rall)%md;
        c.all=min(a.all*b.all,inf);
        if(min(a.suf*b.pre,inf)>a.y){
            c.y=b.y;
            c.pre=min(a.all*b.pre,inf);
            c.suf=b.suf;
            c.ans=(a.rall*b.ans)%md;
        }else{
            c.y=a.y;
            c.pre=a.pre;
            c.suf=min(a.suf*b.all,inf);
            c.ans=a.ans;
        }
        return c;
    }
};
struct segtree{
    node info[2000005];
    void upd(int st,int en,int i,int pos,node val){
        if(st>pos||en<pos)return;
        if(st==en)return void(info[i]=val);
        int m=(st+en)/2;
        upd(st,m,i*2,pos,val);
        upd(m+1,en,i*2+1,pos,val);
        info[i]=info[i*2]+info[i*2+1];
    }
    void build(int st,int en,int i){
        //cerr<<st<<' '<<en<<"\n";
        if(st==en)return void(info[i]=node(y[st],x[st],min(x[st]*y[st],inf),1,(x[st]*y[st])%md,x[st]));
        int m=(st+en)/2;
        build(st,m,i*2);
        build(m+1,en,i*2+1);
        info[i]=info[i*2]+info[i*2+1];
    }
}tr;
int init(int N, int X[], int Y[]) {
    n=N;
    for(int i=1;i<=N;i++)x[i]=X[i-1],y[i]=Y[i-1];
    tr.build(1,N,1);
	return tr.info[1].ans;
}

int updateX(int pos, int val) {	
    pos++;
    x[pos]=val;
    tr.upd(1,n,1,pos,node(y[pos],x[pos],min(x[pos]*y[pos],inf),1,(x[pos]*y[pos])%md,x[pos]));
	return tr.info[1].ans;
}

int updateY(int pos, int val) {
	pos++;
    y[pos]=val;
    tr.upd(1,n,1,pos,node(y[pos],x[pos],min(x[pos]*y[pos],inf),1,(x[pos]*y[pos])%md,x[pos]));
	return tr.info[1].ans;
}

Compilation message

horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:55:20: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   55 |  return tr.info[1].ans;
      |         ~~~~~~~~~~~^~~
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:62:20: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   62 |  return tr.info[1].ans;
      |         ~~~~~~~~~~~^~~
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:69:20: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   69 |  return tr.info[1].ans;
      |         ~~~~~~~~~~~^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 36 ms 94292 KB Output is correct
2 Correct 34 ms 94296 KB Output is correct
3 Correct 36 ms 94300 KB Output is correct
4 Correct 35 ms 94296 KB Output is correct
5 Correct 33 ms 94292 KB Output is correct
6 Correct 33 ms 94292 KB Output is correct
7 Correct 34 ms 94292 KB Output is correct
8 Correct 32 ms 94300 KB Output is correct
9 Correct 34 ms 94156 KB Output is correct
10 Correct 38 ms 94288 KB Output is correct
11 Correct 38 ms 94548 KB Output is correct
12 Correct 31 ms 94132 KB Output is correct
13 Correct 33 ms 94288 KB Output is correct
14 Correct 34 ms 94296 KB Output is correct
15 Correct 33 ms 94292 KB Output is correct
16 Correct 34 ms 94292 KB Output is correct
17 Correct 33 ms 94300 KB Output is correct
18 Correct 33 ms 94292 KB Output is correct
19 Correct 33 ms 94288 KB Output is correct
20 Correct 33 ms 94296 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 33 ms 94292 KB Output is correct
2 Correct 40 ms 94288 KB Output is correct
3 Correct 35 ms 94288 KB Output is correct
4 Correct 31 ms 94300 KB Output is correct
5 Correct 37 ms 94548 KB Output is correct
6 Correct 35 ms 94288 KB Output is correct
7 Correct 34 ms 94300 KB Output is correct
8 Correct 34 ms 94300 KB Output is correct
9 Correct 32 ms 94288 KB Output is correct
10 Correct 36 ms 94292 KB Output is correct
11 Correct 37 ms 94296 KB Output is correct
12 Correct 35 ms 94300 KB Output is correct
13 Correct 36 ms 94292 KB Output is correct
14 Correct 35 ms 94292 KB Output is correct
15 Correct 33 ms 94288 KB Output is correct
16 Correct 32 ms 94292 KB Output is correct
17 Correct 34 ms 94300 KB Output is correct
18 Correct 38 ms 94296 KB Output is correct
19 Correct 32 ms 94288 KB Output is correct
20 Correct 32 ms 94292 KB Output is correct
21 Correct 34 ms 94332 KB Output is correct
22 Correct 33 ms 94292 KB Output is correct
23 Correct 37 ms 94364 KB Output is correct
24 Correct 35 ms 94300 KB Output is correct
25 Correct 36 ms 94292 KB Output is correct
26 Correct 34 ms 94296 KB Output is correct
27 Correct 34 ms 94292 KB Output is correct
28 Correct 33 ms 94340 KB Output is correct
29 Correct 38 ms 94300 KB Output is correct
30 Correct 35 ms 94352 KB Output is correct
31 Correct 32 ms 94292 KB Output is correct
32 Correct 37 ms 94284 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 89 ms 110804 KB Output is correct
2 Correct 151 ms 119596 KB Output is correct
3 Correct 129 ms 110856 KB Output is correct
4 Correct 140 ms 114512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 34 ms 94160 KB Output is correct
2 Correct 34 ms 94292 KB Output is correct
3 Correct 34 ms 94308 KB Output is correct
4 Correct 35 ms 94300 KB Output is correct
5 Correct 39 ms 94288 KB Output is correct
6 Correct 33 ms 94300 KB Output is correct
7 Correct 33 ms 94292 KB Output is correct
8 Correct 36 ms 94292 KB Output is correct
9 Correct 35 ms 94300 KB Output is correct
10 Correct 33 ms 94300 KB Output is correct
11 Correct 33 ms 94364 KB Output is correct
12 Correct 34 ms 94292 KB Output is correct
13 Correct 34 ms 94296 KB Output is correct
14 Correct 34 ms 94292 KB Output is correct
15 Correct 33 ms 94196 KB Output is correct
16 Correct 40 ms 94288 KB Output is correct
17 Correct 33 ms 94300 KB Output is correct
18 Correct 33 ms 94180 KB Output is correct
19 Correct 34 ms 94244 KB Output is correct
20 Correct 34 ms 94288 KB Output is correct
21 Correct 34 ms 94288 KB Output is correct
22 Correct 34 ms 94292 KB Output is correct
23 Correct 36 ms 94292 KB Output is correct
24 Correct 35 ms 94300 KB Output is correct
25 Correct 36 ms 94292 KB Output is correct
26 Correct 36 ms 94292 KB Output is correct
27 Correct 38 ms 94292 KB Output is correct
28 Correct 35 ms 94292 KB Output is correct
29 Correct 34 ms 94300 KB Output is correct
30 Correct 33 ms 94168 KB Output is correct
31 Correct 34 ms 94288 KB Output is correct
32 Correct 32 ms 94296 KB Output is correct
33 Correct 68 ms 109908 KB Output is correct
34 Correct 77 ms 110116 KB Output is correct
35 Correct 88 ms 117072 KB Output is correct
36 Correct 91 ms 116816 KB Output is correct
37 Correct 73 ms 108116 KB Output is correct
38 Correct 71 ms 109136 KB Output is correct
39 Correct 59 ms 107940 KB Output is correct
40 Correct 72 ms 111952 KB Output is correct
41 Correct 58 ms 108116 KB Output is correct
42 Correct 58 ms 108188 KB Output is correct
43 Correct 71 ms 112720 KB Output is correct
44 Correct 70 ms 112464 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 37 ms 94288 KB Output is correct
2 Correct 34 ms 94296 KB Output is correct
3 Correct 36 ms 94300 KB Output is correct
4 Correct 38 ms 94256 KB Output is correct
5 Correct 35 ms 94296 KB Output is correct
6 Correct 34 ms 94292 KB Output is correct
7 Correct 34 ms 94380 KB Output is correct
8 Correct 41 ms 94292 KB Output is correct
9 Correct 36 ms 94300 KB Output is correct
10 Correct 34 ms 94300 KB Output is correct
11 Correct 35 ms 94292 KB Output is correct
12 Correct 34 ms 94284 KB Output is correct
13 Correct 35 ms 94292 KB Output is correct
14 Correct 35 ms 94308 KB Output is correct
15 Correct 37 ms 94288 KB Output is correct
16 Correct 36 ms 94300 KB Output is correct
17 Correct 36 ms 94156 KB Output is correct
18 Correct 34 ms 94300 KB Output is correct
19 Correct 34 ms 94300 KB Output is correct
20 Correct 34 ms 94288 KB Output is correct
21 Correct 34 ms 94300 KB Output is correct
22 Correct 35 ms 94288 KB Output is correct
23 Correct 39 ms 94292 KB Output is correct
24 Correct 36 ms 94296 KB Output is correct
25 Correct 36 ms 94352 KB Output is correct
26 Correct 37 ms 94300 KB Output is correct
27 Correct 35 ms 94292 KB Output is correct
28 Correct 38 ms 94300 KB Output is correct
29 Correct 37 ms 94352 KB Output is correct
30 Correct 36 ms 94292 KB Output is correct
31 Correct 36 ms 94292 KB Output is correct
32 Correct 37 ms 94292 KB Output is correct
33 Correct 100 ms 110928 KB Output is correct
34 Correct 153 ms 119636 KB Output is correct
35 Correct 122 ms 110748 KB Output is correct
36 Correct 141 ms 114732 KB Output is correct
37 Correct 70 ms 110004 KB Output is correct
38 Correct 73 ms 110096 KB Output is correct
39 Correct 90 ms 117064 KB Output is correct
40 Correct 88 ms 117068 KB Output is correct
41 Correct 61 ms 108308 KB Output is correct
42 Correct 62 ms 109140 KB Output is correct
43 Correct 56 ms 108144 KB Output is correct
44 Correct 70 ms 111952 KB Output is correct
45 Correct 57 ms 108024 KB Output is correct
46 Correct 57 ms 108112 KB Output is correct
47 Correct 70 ms 112468 KB Output is correct
48 Correct 72 ms 112400 KB Output is correct
49 Correct 129 ms 112076 KB Output is correct
50 Correct 131 ms 112356 KB Output is correct
51 Correct 117 ms 118864 KB Output is correct
52 Correct 117 ms 118356 KB Output is correct
53 Correct 122 ms 110420 KB Output is correct
54 Correct 94 ms 110856 KB Output is correct
55 Correct 85 ms 109140 KB Output is correct
56 Correct 102 ms 113788 KB Output is correct
57 Correct 90 ms 109716 KB Output is correct
58 Correct 86 ms 110180 KB Output is correct
59 Correct 72 ms 112464 KB Output is correct