Submission #310454

# Submission time Handle Problem Language Result Execution time Memory
310454 2020-10-07T03:21:20 Z juggernaut Horses (IOI15_horses) C++14
100 / 100
301 ms 54264 KB
#include"horses.h"
#include<bits/stdc++.h>
//#include"grader.cpp"
using namespace std;
typedef long long int ll;
ll mod=1e9+7;
struct node{
    struct temp1{
        double res,x,y;
    }lg;
    struct temp2{
        ll res,x,y;
    }md;
}tree[1<<20];
void up(int v){
    if(!v)return;
    int x=(v<<1),y=x+1;
    tree[v].lg.x=tree[x].lg.x+tree[y].lg.x,tree[v].md.x=(tree[x].md.x*tree[y].md.x)%mod;
    if(tree[x].lg.res>=tree[x].lg.x+tree[y].lg.res)tree[v].lg.res=tree[x].lg.res,tree[v].md.res=tree[x].md.res;
    else tree[v].lg.res=tree[x].lg.x+tree[y].lg.res,tree[v].md.res=(tree[x].md.x*tree[y].md.res)%mod;
    up(v>>1);
}
void update(int v,int x,int y){
    v+=(1<<19);
    if(x)tree[v].md.x=x,tree[v].lg.x=log2(x);
    if(y)tree[v].md.y=y,tree[v].lg.y=log2(y);
    tree[v].md.res=(tree[v].md.x*tree[v].md.y)%mod,tree[v].lg.res=tree[v].lg.x+tree[v].lg.y;
    up(v>>1);
}
int init(int N,int X[],int Y[]){
	for(int i=0;i<N;i++)update(i,X[i],Y[i]);
	return tree[1].md.res;
}
int updateX(int pos,int val){
    update(pos,val,0);
    return tree[1].md.res;
}
int updateY(int pos,int val){
    update(pos,0,val);
    return tree[1].md.res;
}

Compilation message

horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:32:20: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   32 |  return tree[1].md.res;
      |         ~~~~~~~~~~~^~~
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:36:23: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   36 |     return tree[1].md.res;
      |            ~~~~~~~~~~~^~~
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:40:23: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   40 |     return tree[1].md.res;
      |            ~~~~~~~~~~~^~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 1 ms 388 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 1 ms 384 KB Output is correct
18 Correct 1 ms 384 KB Output is correct
19 Correct 0 ms 384 KB Output is correct
20 Correct 1 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 0 ms 384 KB Output is correct
15 Correct 0 ms 384 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 1 ms 384 KB Output is correct
18 Correct 1 ms 384 KB Output is correct
19 Correct 1 ms 384 KB Output is correct
20 Correct 1 ms 384 KB Output is correct
21 Correct 1 ms 384 KB Output is correct
22 Correct 1 ms 384 KB Output is correct
23 Correct 1 ms 512 KB Output is correct
24 Correct 1 ms 512 KB Output is correct
25 Correct 1 ms 512 KB Output is correct
26 Correct 1 ms 512 KB Output is correct
27 Correct 1 ms 512 KB Output is correct
28 Correct 1 ms 512 KB Output is correct
29 Correct 1 ms 512 KB Output is correct
30 Correct 1 ms 512 KB Output is correct
31 Correct 1 ms 512 KB Output is correct
32 Correct 2 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 205 ms 54264 KB Output is correct
2 Correct 301 ms 53496 KB Output is correct
3 Correct 243 ms 53112 KB Output is correct
4 Correct 275 ms 53180 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 1 ms 384 KB Output is correct
18 Correct 1 ms 384 KB Output is correct
19 Correct 1 ms 384 KB Output is correct
20 Correct 1 ms 384 KB Output is correct
21 Correct 1 ms 384 KB Output is correct
22 Correct 1 ms 384 KB Output is correct
23 Correct 1 ms 512 KB Output is correct
24 Correct 1 ms 512 KB Output is correct
25 Correct 1 ms 512 KB Output is correct
26 Correct 1 ms 512 KB Output is correct
27 Correct 1 ms 512 KB Output is correct
28 Correct 1 ms 512 KB Output is correct
29 Correct 1 ms 512 KB Output is correct
30 Correct 1 ms 512 KB Output is correct
31 Correct 1 ms 512 KB Output is correct
32 Correct 1 ms 512 KB Output is correct
33 Correct 155 ms 51900 KB Output is correct
34 Correct 158 ms 52216 KB Output is correct
35 Correct 223 ms 52984 KB Output is correct
36 Correct 223 ms 53112 KB Output is correct
37 Correct 130 ms 52216 KB Output is correct
38 Correct 184 ms 52216 KB Output is correct
39 Correct 125 ms 52216 KB Output is correct
40 Correct 201 ms 52344 KB Output is correct
41 Correct 127 ms 52344 KB Output is correct
42 Correct 126 ms 52216 KB Output is correct
43 Correct 193 ms 52216 KB Output is correct
44 Correct 194 ms 52216 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 1 ms 384 KB Output is correct
18 Correct 1 ms 384 KB Output is correct
19 Correct 1 ms 384 KB Output is correct
20 Correct 1 ms 384 KB Output is correct
21 Correct 1 ms 384 KB Output is correct
22 Correct 1 ms 384 KB Output is correct
23 Correct 1 ms 512 KB Output is correct
24 Correct 1 ms 512 KB Output is correct
25 Correct 1 ms 512 KB Output is correct
26 Correct 1 ms 512 KB Output is correct
27 Correct 1 ms 512 KB Output is correct
28 Correct 1 ms 512 KB Output is correct
29 Correct 1 ms 512 KB Output is correct
30 Correct 1 ms 512 KB Output is correct
31 Correct 1 ms 512 KB Output is correct
32 Correct 1 ms 512 KB Output is correct
33 Correct 212 ms 53512 KB Output is correct
34 Correct 300 ms 53872 KB Output is correct
35 Correct 243 ms 53112 KB Output is correct
36 Correct 276 ms 53240 KB Output is correct
37 Correct 155 ms 52216 KB Output is correct
38 Correct 157 ms 52216 KB Output is correct
39 Correct 222 ms 52940 KB Output is correct
40 Correct 222 ms 52856 KB Output is correct
41 Correct 128 ms 52216 KB Output is correct
42 Correct 184 ms 52216 KB Output is correct
43 Correct 126 ms 52220 KB Output is correct
44 Correct 197 ms 52216 KB Output is correct
45 Correct 126 ms 52356 KB Output is correct
46 Correct 128 ms 52216 KB Output is correct
47 Correct 193 ms 52216 KB Output is correct
48 Correct 192 ms 52216 KB Output is correct
49 Correct 231 ms 53244 KB Output is correct
50 Correct 231 ms 53112 KB Output is correct
51 Correct 257 ms 53752 KB Output is correct
52 Correct 272 ms 53752 KB Output is correct
53 Correct 198 ms 53240 KB Output is correct
54 Correct 233 ms 53112 KB Output is correct
55 Correct 154 ms 52344 KB Output is correct
56 Correct 241 ms 53240 KB Output is correct
57 Correct 158 ms 53112 KB Output is correct
58 Correct 163 ms 53244 KB Output is correct
59 Correct 192 ms 52220 KB Output is correct