Submission #20466

#TimeUsernameProblemLanguageResultExecution timeMemory
20466책상다리황새두렁넘기 (#35)초음속철도 (OJUZ11_rail)C++11
45 / 100
9 ms18552 KiB
#include<bits/stdc++.h> #define X first #define Y second using namespace std; typedef long long ll; const ll mod = 1e9+7; ll m, n, two[100005], sz; pair<ll,ll> a[100005]; vector<ll> cpr; struct segtree { ll val[888888], lazy[888888]; void lazydown (ll P) { val[2*P] = (val[2*P] * two[lazy[P]]) % mod; lazy[2*P] += lazy[P]; val[2*P+1] = (val[2*P+1] * two[lazy[P]]) % mod; lazy[2*P+1] += lazy[P]; lazy[P] = 0; } void pl (ll SS, ll SE, ll X, ll P, ll V) { if(SE < X || X < SS) return; if(SS == SE) {val[P] += V; return;} lazydown(P); ll mid = (SS+SE)/2; pl(SS, mid, X, 2*P, V); pl(mid+1, SE, X, 2*P+1, V); val[P] = (val[2*P] + val[2*P+1]) % mod; } void pl(ll X, ll V) {pl(0, sz-1, X, 1, V);} void ml (ll SS, ll SE, ll S, ll E, ll P, ll V) { if(S <= SS && SE <= E) { val[P] = (val[P] * two[V]) % mod; lazy[P] += V; return; } if(SE < S || E < SS) return; lazydown(P); ll mid = (SS+SE)/2; ml(SS, mid, S, E, 2*P, V); ml(mid+1, SE, S, E, 2*P+1, V); val[P] = (val[2*P] + val[2*P+1]) % mod; } void ml (ll S, ll E, ll V) {ml(0, sz-1, S, E, 1, V);} ll query (ll SS, ll SE, ll S, ll E, ll P) { if(S <= SS && SE <= E) return val[P]; if(SE < S || E < SS) return 0; lazydown(P); ll mid = (SS+SE)/2; return (query(SS, mid, S, E, 2*P) + query(mid+1, SE, S, E, 2*P+1)) % mod; } ll query (ll S, ll E) {return query(0, sz-1, S, E, 1);} } seg; int main() { scanf("%lld%lld",&m,&n); two[0] = 1; for(int i=1;i<=n;i++) { two[i] = (two[i-1] * 2) % mod; } for(int i=1;i<=n;i++) { scanf("%lld%lld",&a[i].X,&a[i].Y); cpr.push_back(a[i].X); cpr.push_back(a[i].Y); } sort(cpr.begin(), cpr.end()); cpr.erase(unique(cpr.begin(), cpr.end()), cpr.end()); if(cpr[0] != 1 || cpr.back() != m) {puts("0"); return 0;} for(int i=1;i<=n;i++) { a[i].X = lower_bound(cpr.begin(), cpr.end(), a[i].X) - cpr.begin(); a[i].Y = lower_bound(cpr.begin(), cpr.end(), a[i].Y) - cpr.begin(); } sort(a+1, a+1+n); sz = cpr.size(); seg.pl(0, 1); for(int i=1;i<=n;i++) { seg.pl(a[i].Y, seg.query(a[i].X, a[i].Y)); seg.ml(a[i].Y+1, sz-1, 1); } printf("%lld\n",seg.query(sz-1, sz-1)); }

Compilation message (stderr)

rail.cpp: In function 'int main()':
rail.cpp:58:25: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld%lld",&m,&n);
                         ^
rail.cpp:64:36: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld%lld",&a[i].X,&a[i].Y);
                                    ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...