제출 #739459

#제출 시각아이디문제언어결과실행 시간메모리
739459Alihan_8Boat (APIO16_boat)C++17
0 / 100
26 ms32220 KiB
#include <bits/stdc++.h> using namespace std; #define all(x) x.begin(), x.end() #define pb push_back #define ln '\n' #define int long long template <class _T> bool chmin(_T &x, const _T &y){ bool flag = false; if ( x > y ){ x = y; flag |= true; } return flag; } template <class _T> bool chmax(_T &x, const _T &y){ bool flag = false; if ( x < y ){ x = y; flag |= true; } return flag; } signed main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; vector <int> a(n), b(n), pos; for ( int i = 0; i < n; i++ ){ cin >> a[i] >> b[i]; pos.pb(a[i]); pos.pb(b[i]); } sort(all(pos)); pos.resize(unique(all(pos)) - pos.begin()); auto id = [&](int x){ return lower_bound(all(pos), x) - pos.begin() + 1; }; const int Mod = 1e9 + 7, N = 1e6 + 1; auto add = [&](int &x, const int &y){ x = (x + y) % Mod; if ( x < 0 ) x += Mod; }; vector <int> dp(N), pref(N, 1); dp[0] = 1; for ( int i = 1; i <= n; i++ ){ for ( int j = a[i - 1]; j <= b[i - 1]; j++ ){ add(dp[j], pref[j - 1]); } for ( int j = 1; j < N; j++ ){ pref[j] = (pref[j - 1] + dp[j]) % Mod; } } int res = pref.back(); add(res, -1); cout << res; cout << '\n'; }

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

boat.cpp: In function 'int main()':
boat.cpp:40:10: warning: variable 'id' set but not used [-Wunused-but-set-variable]
   40 |     auto id = [&](int x){
      |          ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...