이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "horses.h"
using namespace std;
const int N = 5e5 + 10;
struct node{
double log;
long long va;
node() : log( 0 ), va( 1 ) { }
node( double log, long long va ) : log( log ), va( va ) { }
friend node operator+( const node &a, const node &b ) {
node ret;
ret.log = a.log + b.log;
ret.va = ( a.va * b.va ) % mod;
return ret;
}
friend bool operator<( const node &a, const node &b ) {
return make_pair( a.log, a.va ) < make_pair( b.log, b.va );
}
} seg[4*N], lz[4*N];
int n, x[N], y[N];
node a[N];
void build( int l = 1, int r = n, int now = 1 ) {
if( l == r ) return void( t[now] = a[l-1] );
int mid = ( l + r ) >> 1;
build( l, mid, now << 1 ), build( mid + 1, r, now << 1 | 1 );
t[now] = t[now<<1] < t[now<<1|1] ? t[now<<1|1] : t[now<<1];
return ;
}
void push( int now, int l, int r ) {
t[now] = t[now] + lz[now];
if( l != r ) {
lz[now<<1] = lz[now<<1] + lz[now];
lz[now<<1|1] = lz[now<<1|1] + lz[now];
}
lz[now] = node( 0, 1 );
return ;
}
void update( int ll, int rr, node k, int l = 1, int r = n, int now = 1 ) {
push( now, l, r );
if( l > rr || r < ll ) return ;
if( l >= ll && r <= rr ) {
lz[now] = lz[now] + k;
push( now, l, r );
return ;
}
int mid = ( l + r ) >> 1;
update( ll, rr, k, l, mid, now << 1 ), update( ll, rr, k, mid + 1, r, now << 1 | 1 );
t[now] = t[now<<1] < t[now<<1|1] ? t[now<<1|1] : t[now<<1];
}
int init( int N, int X[], int Y[] ) {
n = N;
node cul( 0, 1 );
for( int i = 0 ; i < n ; i++ ) {
x[i] = X[i], y[i] = Y[i];
cul = cul + node( ( double )log2( x[i] ), x[i] );
a[i] = cul + node( ( double )log2( y[i] ), y[i] );
}
build();
return t[1].va;
}
long long modpower( long long base, long long power ) {
long long ret = 1;
for( ; power ; power >>= 1 ) {
if( power & 1 ) ret = ( ret * base ) % mod;
base = ( base * base ) % mod;
}
return ret;
}
int updatex( int pos, int val ) {
double ll = ( double )log2( val ) - ( double )log2( x[pos] );
long long vc = ( long long )( 1ll * val * modpower( x[pos], mod - 2 ) ) % mod;
x[pos] = val;
update( pos + 1, n, node( ll, ss ) );
return seg[1].va;
}
int updatey( int pos, int val ) {
double ll = ( double )log2( val ) - ( double )log2( y[pos] );
long long vc = ( long long )( 1ll * val * modpower( y[pos], mod - 2 ) ) % mod;
y[pos] = val;
update( pos + 1, pos + 1, node( ll, vc ) );
return t[1].va;
}
컴파일 시 표준 에러 (stderr) 메시지
horses.cpp: In constructor 'node::node(double, long long int)':
horses.cpp:12:38: warning: declaration of 'va' shadows a member of 'node' [-Wshadow]
node( double log, long long va ) : log( log ), va( va ) { }
^
horses.cpp:10:15: note: shadowed declaration is here
long long va;
^~
horses.cpp:12:38: warning: declaration of 'log' shadows a member of 'node' [-Wshadow]
node( double log, long long va ) : log( log ), va( va ) { }
^
horses.cpp:9:12: note: shadowed declaration is here
double log;
^~~
horses.cpp: In function 'node operator+(const node&, const node&)':
horses.cpp:16:36: error: 'mod' was not declared in this scope
ret.va = ( a.va * b.va ) % mod;
^~~
horses.cpp:16:36: note: suggested alternative: 'modf'
ret.va = ( a.va * b.va ) % mod;
^~~
modf
horses.cpp: In function 'void build(int, int, int)':
horses.cpp:28:31: error: 't' was not declared in this scope
if( l == r ) return void( t[now] = a[l-1] );
^
horses.cpp:28:47: error: return-statement with a value, in function returning 'void' [-fpermissive]
if( l == r ) return void( t[now] = a[l-1] );
^
horses.cpp:31:5: error: 't' was not declared in this scope
t[now] = t[now<<1] < t[now<<1|1] ? t[now<<1|1] : t[now<<1];
^
horses.cpp: In function 'void push(int, int, int)':
horses.cpp:36:5: error: 't' was not declared in this scope
t[now] = t[now] + lz[now];
^
horses.cpp: In function 'void update(int, int, node, int, int, int)':
horses.cpp:55:5: error: 't' was not declared in this scope
t[now] = t[now<<1] < t[now<<1|1] ? t[now<<1|1] : t[now<<1];
^
horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:58:35: warning: declaration of 'N' shadows a global declaration [-Wshadow]
int init( int N, int X[], int Y[] ) {
^
horses.cpp:6:11: note: shadowed declaration is here
const int N = 5e5 + 10;
^
horses.cpp:67:12: error: 't' was not declared in this scope
return t[1].va;
^
horses.cpp: In function 'long long int modpower(long long int, long long int)':
horses.cpp:73:48: error: 'mod' was not declared in this scope
if( power & 1 ) ret = ( ret * base ) % mod;
^~~
horses.cpp:73:48: note: suggested alternative: 'modf'
if( power & 1 ) ret = ( ret * base ) % mod;
^~~
modf
horses.cpp:74:34: error: 'mod' was not declared in this scope
base = ( base * base ) % mod;
^~~
horses.cpp:74:34: note: suggested alternative: 'modf'
base = ( base * base ) % mod;
^~~
modf
horses.cpp: In function 'int updatex(int, int)':
horses.cpp:81:65: error: 'mod' was not declared in this scope
long long vc = ( long long )( 1ll * val * modpower( x[pos], mod - 2 ) ) % mod;
^~~
horses.cpp:81:65: note: suggested alternative: 'modf'
long long vc = ( long long )( 1ll * val * modpower( x[pos], mod - 2 ) ) % mod;
^~~
modf
horses.cpp:83:35: error: 'ss' was not declared in this scope
update( pos + 1, n, node( ll, ss ) );
^~
horses.cpp:84:19: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
return seg[1].va;
~~~~~~~^~
horses.cpp:81:15: warning: unused variable 'vc' [-Wunused-variable]
long long vc = ( long long )( 1ll * val * modpower( x[pos], mod - 2 ) ) % mod;
^~
horses.cpp: In function 'int updatey(int, int)':
horses.cpp:89:65: error: 'mod' was not declared in this scope
long long vc = ( long long )( 1ll * val * modpower( y[pos], mod - 2 ) ) % mod;
^~~
horses.cpp:89:65: note: suggested alternative: 'modf'
long long vc = ( long long )( 1ll * val * modpower( y[pos], mod - 2 ) ) % mod;
^~~
modf
horses.cpp:92:12: error: 't' was not declared in this scope
return t[1].va;
^