Submission #310454

#TimeUsernameProblemLanguageResultExecution timeMemory
310454juggernautHorses (IOI15_horses)C++14
100 / 100
301 ms54264 KiB
#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 (stderr)

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...