제출 #108816

#제출 시각아이디문제언어결과실행 시간메모리
108816DodgeBallMan말 (IOI15_horses)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #include "horses.h" using namespace std; const int N = 5e5 + 10; const int mod = 1e9 + 7; 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 seg[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, vc ) ); 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 seg[1].va; }

컴파일 시 표준 에러 (stderr) 메시지

horses.cpp: In constructor 'node::node(double, long long int)':
horses.cpp:13:38: warning: declaration of 'va' shadows a member of 'node' [-Wshadow]
     node( double log, long long va ) : log( log ), va( va ) { }
                                      ^
horses.cpp:11:15: note: shadowed declaration is here
     long long va;
               ^~
horses.cpp:13:38: warning: declaration of 'log' shadows a member of 'node' [-Wshadow]
     node( double log, long long va ) : log( log ), va( va ) { }
                                      ^
horses.cpp:10:12: note: shadowed declaration is here
     double log;
            ^~~
horses.cpp: In function 'void build(int, int, int)':
horses.cpp:29:31: error: 't' was not declared in this scope
     if( l == r ) return void( t[now] = a[l-1] );
                               ^
horses.cpp:29:47: error: return-statement with a value, in function returning 'void' [-fpermissive]
     if( l == r ) return void( t[now] = a[l-1] );
                                               ^
horses.cpp:32: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:37: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:56: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:59: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:68:19: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
     return seg[1].va;
            ~~~~~~~^~
horses.cpp: In function 'int updatex(int, int)':
horses.cpp:85:19: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
     return seg[1].va;
            ~~~~~~~^~
horses.cpp: In function 'int updatey(int, int)':
horses.cpp:93:19: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
     return seg[1].va;
            ~~~~~~~^~