제출 #209582

#제출 시각아이디문제언어결과실행 시간메모리
209582LawlietBoat (APIO16_boat)C++14
31 / 100
1238 ms524292 KiB
#include <bits/stdc++.h> using namespace std; typedef long long int lli; const int MAXN = 510; const int MAXV = 1000000000; const int MOD = 1000000007; class SparseSegmentTree { public: void create() { e.push_back( 0 ); d.push_back( 0 ); sum.push_back( 0 ); } int getLeft(int node) { if( e[node] == 0 ) { e[node] = ++cntNode; create(); } return e[node]; } int getRight(int node) { if( d[node] == 0 ) { d[node] = ++cntNode; create(); } return d[node]; } void update(int node, int l, int r, int i, int v) { if( i < l || r < i ) return; if( l == r ) { sum[node] += v; sum[node] %= MOD; return; } int m = ( l + r )/2; if( i <= m ) update( getLeft(node) , l , m , i , v ); else update( getRight(node) , m + 1 , r , i , v ); sum[node] = sum[ e[node] ] + sum[ d[node] ]; sum[node] %= MOD; } int query(int node, int l, int r, int i, int j) { if( node == 0 ) return 0; if( j < l || r < i ) return 0; if( i <= l && r <= j ) return sum[node]; int m = ( l + r )/2; int sumLeft = query( e[node] , l , m , i , j ); int sumRight = query( d[node] , m + 1 , r , i , j ); return ( sumLeft + sumRight )%MOD; } SparseSegmentTree() : cntNode(1) { create(); create(); } private: int cntNode; vector< int > e, d; vector< int > sum; }; int n; SparseSegmentTree SEG; int main() { scanf("%d",&n); SEG.update( 1 , 0 , MAXV , 0 , 1 ); for(int i = 1 ; i <= n ; i++) { int l, r; scanf("%d %d",&l,&r); vector< int > aux; for(int j = l ; j <= r ; j++) aux.push_back( SEG.query( 1 , 0 , MAXV , 0 , j - 1 ) ); for(int j = 0 ; j < aux.size() ; j++) SEG.update( 1 , 0 , MAXV , j + l , aux[j] ); } printf("%d\n",SEG.query( 1 , 0 , MAXV , 1 , MAXV )); }

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

boat.cpp: In function 'int main()':
boat.cpp:108:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int j = 0 ; j < aux.size() ; j++)
                   ~~^~~~~~~~~~~~
boat.cpp:94:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&n);
  ~~~~~^~~~~~~~~
boat.cpp:101:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d",&l,&r);
   ~~~~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...