제출 #74695

#제출 시각아이디문제언어결과실행 시간메모리
74695VardanyanBoat (APIO16_boat)C++14
0 / 100
1541 ms525312 KiB
//#pragma GCC optimize "-O3" #include <bits/stdc++.h> using namespace std; int a[505],b[505]; const int MOD = 1000*1000*1000+7; struct node{ node *l; node *r; int val; node():l(NULL),r(NULL),val(0){} }; void update(node *v, int s,int e,int l,int r,int val){ if(l>r) return; if(s == l && e == r){ v->val += val; return; } int m = (s+e)/2; if(v->l == NULL){ v->l = new node(); v->r = new node(); } update(v->l,s,m,l,min(m,r),val); update(v->r,m+1,e,max(l,m+1),r,val); v->val = (v->l->val+v->r->val)%MOD; } int query(node *v, int s,int e,int l,int r){ if(v == NULL) return 0; if(l>r) return 0; if(s == l && e == r) return v->val; int m = (s+e)/2; return (query(v->l,s,m,l,min(m,r))+query(v->r,m+1,e,max(l,m+1),r))%MOD; } int main(){ int n; scanf("%d",&n); for(int i = 1;i<=n;i++){ scanf("%d%d",&a[i],&b[i]); } node* root = new node();; for(int i = 1;i<=n;i++){ vector<int> v; int p = 0; for(int j = a[i];j<=b[i];j++){ int x = query(root,1,1000*1000*1000,1,j-1); v.push_back(x); } for(int j = a[i];j<=b[i];j++){ update(root,1,1000*1000*1000,j,j,v[p]+1); p++; } } cout<<query(root,1,1000*1000*1000,1,1000*1000*1000)<<endl; return 0; }

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

boat.cpp: In function 'int main()':
boat.cpp:36:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&n);
     ~~~~~^~~~~~~~~
boat.cpp:38:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d",&a[i],&b[i]);
         ~~~~~^~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...