Submission #30821

# Submission time Handle Problem Language Result Execution time Memory
30821 2017-07-27T08:43:10 Z inqr Horses (IOI15_horses) C++14
0 / 100
563 ms 72412 KB
#include "horses.h"
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define rt insert
#define st first
#define nd second
#define ll long long
#define pii pair < int , int >
#define DB printf("debug\n");
#define umax( x , y ) x = max( x , (y) )
#define umin( x , y ) x = min( x , (y) )
#define all(x) x.begin() , x.end()
#define MAXN 500005
#define MOD (ll)1e9+7
using namespace std;
int n;
int x[MAXN],y[MAXN];
struct segmenttree{
	pair<double,ll> st[4*MAXN];
	pair<double,ll> lz[4*MAXN];
	segmenttree(){
		for(int i=0;i<4*MAXN;i++){
			st[i]=lz[i]={0,1};
		}
	}
	pair<double,ll> merge(pair<double,ll> a,pair<double,ll> b){
		return {a.first+b.first,(a.second*b.second+MOD)%MOD};
	}
	void upd(int ul,int ur,pair<double,ll> up,int l,int r,int stp){
		if(l>r||ur<l||r<ul)return;
		st[stp]=merge(st[stp],lz[stp]);
		if(l!=r){
			lz[stp*2]=lz[stp*2+1]=lz[stp];
		}
		lz[stp]=mp(0,1);
		if(ul<=l&&r<=ur){
			lz[stp]=up;
			st[stp]=merge(lz[stp],st[stp]);
			return;
		}
		int m=(l+r)/2;
		upd(ul,ur,up,l,m,stp*2);upd(ul,ur,up,m+1,r,stp*2+1);
		st[stp]=max(st[stp*2],st[stp*2+1]);
	}
}seg;
ll invert(ll base){
	ll res=1;
	ll exp=MOD-2;
	while(exp>0){
		if(exp&1){
			res*=base;
			res%=MOD;
		}
		base*=base;
		base%=MOD;
		exp/=2;
	}
	return res;
}
int init(int N, int X[], int Y[]) {
	n=N;
	for(int i=0;i<n;i++)x[i]=X[i],y[i]=Y[i];
	for(int i=0;i<n;i++){
		seg.upd(i,n-1,{log2(x[i]),x[i]},0,n-1,1);
		seg.upd(i,i,{log2(y[i]),y[i]},0,n-1,1);
	}
	return seg.st[1].nd;
}
int updateX(int pos, int val){	
	seg.upd(pos,n-1,{-log2(x[pos]) , invert(x[pos]) },0,n-1,1);
	x[pos]=val;
	seg.upd(pos,n-1,{log2(x[pos]) ,x[pos] },0,n-1,1);
	return seg.st[1].nd;
}
int updateY(int pos, int val) {
	seg.upd(pos,pos,{-log2(y[pos]),invert(y[pos])},0,n-1,1);
	y[pos]=val;
	seg.upd(pos,pos,{log2(y[pos]) ,y[pos] },0,n-1,1);
	return seg.st[1].nd;
}

Compilation message

horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:7:12: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
 #define nd second
            ^
horses.cpp:68:19: note: in expansion of macro 'nd'
  return seg.st[1].nd;
                   ^
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:7:12: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
 #define nd second
            ^
horses.cpp:74:19: note: in expansion of macro 'nd'
  return seg.st[1].nd;
                   ^
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:7:12: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
 #define nd second
            ^
horses.cpp:80:19: note: in expansion of macro 'nd'
  return seg.st[1].nd;
                   ^
# Verdict Execution time Memory Grader output
1 Incorrect 23 ms 68500 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 19 ms 68500 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 563 ms 72412 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 16 ms 68500 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 23 ms 68500 KB Output isn't correct
2 Halted 0 ms 0 KB -