답안 #874132

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
874132 2023-11-16T09:48:02 Z HuyQuang_re_Zero 말 (IOI15_horses) C++14
100 / 100
520 ms 62120 KB
#include <bits/stdc++.h>
#define ll long long
#define db long double
#define II pair <ll,ll>
#define III pair <ll,II>
#define IV pair <vector <int>,vector <int> >
#define TII pair <treap*,treap*>
#define fst first
#define snd second
#define BIT(x,i) ((x>>i)&1)
#define pi acos(-1)
#define to_radian(x) (x*pi/180.0)
#define to_degree(x) (x*180.0/pi)
#define Log(x) (31-__builtin_clz((int)x))
#define LogLL(x) (63-__builtin_clzll((ll)x))
#include "horses.h"
using namespace std;
const ll mod=round(1e9)+7;
set <int> s;
struct pt { ll x,y; };
pt operator + (pt a,pt b) { return { a.x*b.x%mod,max(a.y,b.y) }; }
int x[500005],y[500005],n,i,u,q,type,pos,val;
struct Interval_Tree
{
    pt st[4*500005];
    void update(int id,int l,int r,int u)
    {
        if(l==r) { st[id]={ x[u],y[u] }; return ; }
        int mid=(l+r)>>1;
        if(u<=mid) update(id*2,l,mid,u);
        else update(id*2+1,mid+1,r,u);
        st[id]=st[id*2]+st[id*2+1];
    }
    pt get(int id,int l,int r,int u,int v)
    {
        if(u>r || v<l) return { 1,0 };
        if(u<=l && r<=v) return st[id];
        int mid=(l+r)>>1;
        return get(id*2,l,mid,u,v)+get(id*2+1,mid+1,r,u,v);
    }
} IT;
int Cal()
{
    set <int>::iterator it=s.end();
    ll ma=0,res=0,last=n+1;
    while(it!=s.begin())
    {
        it--;
        int u=*it;
        ll k=IT.get(1,1,n,u,last-1).y;
        if(ma<k)
        {
            ma=k;
            res=IT.get(1,1,n,1,u).x*ma%mod;
        }
        ma=ma*x[u];
        if(ma>round(1e9)) break;
        last=u;
    }
    return res;
}
int init(int _n,int _x[],int _y[])
{
    n=_n;
    s.insert(0);
    for(i=n;i>=1;i--)
    {
        x[i]=_x[i-1],y[i]=_y[i-1];
        if(x[i]>=2) s.insert(i);
        IT.update(1,1,n,i);
    }
    x[0]=1;
    return Cal();
}
int updateX(int u,int k)
{
    u++;
    s.erase(u);
    x[u]=k;
    if(x[u]>=2) s.insert(u);
    IT.update(1,1,n,u);
    return Cal();
}
int updateY(int u,int k)
{
    u++;
    y[u]=k;
    IT.update(1,1,n,u);
    return Cal();
}
/*
int main()
{
    freopen("horse.inp","r",stdin);
    freopen("horse.out","w",stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin>>n;
    for(i=0;i<n;i++) cin>>x[i];
    for(i=0;i<n;i++) cin>>y[i];
    cout<<init(n,x,y)<<'\n';
    cin>>q;
    while(q--)
    {
        cin>>type>>pos>>val;
        if(type==1) cout<<updateX(pos,val)<<'\n';
        else cout<<updateY(pos,val)<<'\n';
    }
}
*/

Compilation message

horses.cpp: In member function 'void Interval_Tree::update(int, int, int, int)':
horses.cpp:26:40: warning: declaration of 'u' shadows a global declaration [-Wshadow]
   26 |     void update(int id,int l,int r,int u)
      |                                    ~~~~^
horses.cpp:22:29: note: shadowed declaration is here
   22 | int x[500005],y[500005],n,i,u,q,type,pos,val;
      |                             ^
horses.cpp: In member function 'pt Interval_Tree::get(int, int, int, int, int)':
horses.cpp:34:35: warning: declaration of 'u' shadows a global declaration [-Wshadow]
   34 |     pt get(int id,int l,int r,int u,int v)
      |                               ~~~~^
horses.cpp:22:29: note: shadowed declaration is here
   22 | int x[500005],y[500005],n,i,u,q,type,pos,val;
      |                             ^
horses.cpp: In function 'int Cal()':
horses.cpp:49:13: warning: declaration of 'u' shadows a global declaration [-Wshadow]
   49 |         int u=*it;
      |             ^
horses.cpp:22:29: note: shadowed declaration is here
   22 | int x[500005],y[500005],n,i,u,q,type,pos,val;
      |                             ^
horses.cpp:50:33: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   50 |         ll k=IT.get(1,1,n,u,last-1).y;
      |                             ~~~~^~
horses.cpp:57:12: warning: conversion from 'long long int' to 'double' may change value [-Wconversion]
   57 |         if(ma>round(1e9)) break;
      |            ^~
horses.cpp:60:12: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   60 |     return res;
      |            ^~~
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:75:17: warning: declaration of 'u' shadows a global declaration [-Wshadow]
   75 | int updateX(int u,int k)
      |             ~~~~^
horses.cpp:22:29: note: shadowed declaration is here
   22 | int x[500005],y[500005],n,i,u,q,type,pos,val;
      |                             ^
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:84:17: warning: declaration of 'u' shadows a global declaration [-Wshadow]
   84 | int updateY(int u,int k)
      |             ~~~~^
horses.cpp:22:29: note: shadowed declaration is here
   22 | int x[500005],y[500005],n,i,u,q,type,pos,val;
      |                             ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4536 KB Output is correct
8 Correct 1 ms 4528 KB Output is correct
9 Correct 1 ms 4444 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
11 Correct 1 ms 4440 KB Output is correct
12 Correct 1 ms 4444 KB Output is correct
13 Correct 1 ms 4444 KB Output is correct
14 Correct 1 ms 4444 KB Output is correct
15 Correct 1 ms 4444 KB Output is correct
16 Correct 1 ms 4444 KB Output is correct
17 Correct 1 ms 4444 KB Output is correct
18 Correct 1 ms 4444 KB Output is correct
19 Correct 1 ms 4444 KB Output is correct
20 Correct 1 ms 4444 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4596 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 4444 KB Output is correct
10 Correct 1 ms 4440 KB Output is correct
11 Correct 1 ms 4444 KB Output is correct
12 Correct 1 ms 4440 KB Output is correct
13 Correct 1 ms 4444 KB Output is correct
14 Correct 1 ms 4444 KB Output is correct
15 Correct 1 ms 4444 KB Output is correct
16 Correct 1 ms 4444 KB Output is correct
17 Correct 1 ms 4444 KB Output is correct
18 Correct 1 ms 4444 KB Output is correct
19 Correct 1 ms 4440 KB Output is correct
20 Correct 1 ms 4444 KB Output is correct
21 Correct 1 ms 4444 KB Output is correct
22 Correct 1 ms 4444 KB Output is correct
23 Correct 1 ms 4444 KB Output is correct
24 Correct 1 ms 4444 KB Output is correct
25 Correct 1 ms 4444 KB Output is correct
26 Correct 1 ms 4444 KB Output is correct
27 Correct 3 ms 4444 KB Output is correct
28 Correct 2 ms 4444 KB Output is correct
29 Correct 1 ms 4444 KB Output is correct
30 Correct 1 ms 4444 KB Output is correct
31 Correct 2 ms 4696 KB Output is correct
32 Correct 3 ms 4440 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 502 ms 51220 KB Output is correct
2 Correct 317 ms 62120 KB Output is correct
3 Correct 328 ms 53364 KB Output is correct
4 Correct 351 ms 57320 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4548 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4528 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 4444 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
11 Correct 1 ms 4444 KB Output is correct
12 Correct 1 ms 4444 KB Output is correct
13 Correct 1 ms 4444 KB Output is correct
14 Correct 1 ms 4444 KB Output is correct
15 Correct 1 ms 4444 KB Output is correct
16 Correct 1 ms 4444 KB Output is correct
17 Correct 1 ms 4444 KB Output is correct
18 Correct 1 ms 4444 KB Output is correct
19 Correct 1 ms 4444 KB Output is correct
20 Correct 1 ms 4444 KB Output is correct
21 Correct 1 ms 4444 KB Output is correct
22 Correct 1 ms 4444 KB Output is correct
23 Correct 1 ms 4444 KB Output is correct
24 Correct 2 ms 4444 KB Output is correct
25 Correct 2 ms 4440 KB Output is correct
26 Correct 1 ms 4444 KB Output is correct
27 Correct 3 ms 4444 KB Output is correct
28 Correct 2 ms 4444 KB Output is correct
29 Correct 1 ms 4444 KB Output is correct
30 Correct 1 ms 4444 KB Output is correct
31 Correct 2 ms 4444 KB Output is correct
32 Correct 3 ms 4440 KB Output is correct
33 Correct 100 ms 25396 KB Output is correct
34 Correct 102 ms 29316 KB Output is correct
35 Correct 218 ms 59708 KB Output is correct
36 Correct 209 ms 59568 KB Output is correct
37 Correct 137 ms 27416 KB Output is correct
38 Correct 148 ms 40128 KB Output is correct
39 Correct 92 ms 27036 KB Output is correct
40 Correct 206 ms 54816 KB Output is correct
41 Correct 107 ms 27220 KB Output is correct
42 Correct 120 ms 27272 KB Output is correct
43 Correct 196 ms 55228 KB Output is correct
44 Correct 189 ms 54992 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4440 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4696 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 4444 KB Output is correct
10 Correct 1 ms 4440 KB Output is correct
11 Correct 1 ms 4440 KB Output is correct
12 Correct 1 ms 4444 KB Output is correct
13 Correct 1 ms 4444 KB Output is correct
14 Correct 1 ms 4444 KB Output is correct
15 Correct 1 ms 4440 KB Output is correct
16 Correct 1 ms 4696 KB Output is correct
17 Correct 1 ms 4444 KB Output is correct
18 Correct 1 ms 4444 KB Output is correct
19 Correct 1 ms 4444 KB Output is correct
20 Correct 1 ms 4444 KB Output is correct
21 Correct 1 ms 4444 KB Output is correct
22 Correct 1 ms 4444 KB Output is correct
23 Correct 1 ms 4444 KB Output is correct
24 Correct 1 ms 4444 KB Output is correct
25 Correct 1 ms 4444 KB Output is correct
26 Correct 1 ms 4444 KB Output is correct
27 Correct 3 ms 4604 KB Output is correct
28 Correct 2 ms 4440 KB Output is correct
29 Correct 1 ms 4440 KB Output is correct
30 Correct 1 ms 4444 KB Output is correct
31 Correct 2 ms 4444 KB Output is correct
32 Correct 3 ms 4440 KB Output is correct
33 Correct 493 ms 51268 KB Output is correct
34 Correct 325 ms 62108 KB Output is correct
35 Correct 312 ms 53428 KB Output is correct
36 Correct 349 ms 57268 KB Output is correct
37 Correct 99 ms 29264 KB Output is correct
38 Correct 98 ms 29260 KB Output is correct
39 Correct 219 ms 59472 KB Output is correct
40 Correct 208 ms 59476 KB Output is correct
41 Correct 137 ms 27408 KB Output is correct
42 Correct 156 ms 40296 KB Output is correct
43 Correct 92 ms 27104 KB Output is correct
44 Correct 207 ms 54844 KB Output is correct
45 Correct 110 ms 27324 KB Output is correct
46 Correct 122 ms 27168 KB Output is correct
47 Correct 190 ms 55120 KB Output is correct
48 Correct 209 ms 54868 KB Output is correct
49 Correct 183 ms 32340 KB Output is correct
50 Correct 167 ms 32132 KB Output is correct
51 Correct 334 ms 61424 KB Output is correct
52 Correct 252 ms 61304 KB Output is correct
53 Correct 520 ms 30624 KB Output is correct
54 Correct 271 ms 44384 KB Output is correct
55 Correct 172 ms 28152 KB Output is correct
56 Correct 262 ms 56288 KB Output is correct
57 Correct 322 ms 28756 KB Output is correct
58 Correct 456 ms 29544 KB Output is correct
59 Correct 188 ms 54868 KB Output is correct