Submission #494007

#TimeUsernameProblemLanguageResultExecution timeMemory
494007BreakOfDawnBoat (APIO16_boat)C++14
0 / 100
4 ms4300 KiB
/* 🛸     🌎 °  🌓 •  .°•   🚀 ✯    ★ *     °    🛰  °·   🪐 .   • ° ★ • ☄ ______________________________________________________ You are watching a brute force code CODE IS WRITTEN BY 13MINUSONE */ #include<bits/stdc++.h> using namespace std; #define task "DUT03TEAMS" #define SZ(c) c.size() #define getbit(x,i) (((x) >> (i)) & 1) #define turnoff(x,i) (x)&(~(1<<(i))) #define mu2(x) (1<<x) #define __builtin_popcount __builtin_popcountll #define all(x) x.begin(),x.end() #define endl '\n' #define fi first #define se second typedef long long ll ; typedef pair<int,int> ii; typedef vector<ll> vll; typedef vector<int> vi; template<class X, class Y> bool minimize(X &x, const Y &y) { X eps = 1e-9; if (x > y + eps) { x = y; return true; } else return false; } template<class X, class Y> bool maximize(X &x, const Y &y) { X eps = 1e-9; if (x + eps < y) { x = y; return true; } else return false; } template<class T> T Abs(const T &x) { return (x < 0 ? -x : x); } const ll N = 1e5 + 5; const ll mod =1e9+9; const ll base = 311; const int block = 488; void fastio() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); } void inti() { if(fopen(task".inp","r")) { freopen(task".inp","r",stdin); freopen(task".out","w",stdout); } } void upd(ll& a, const ll& b) { a = (a + b) % mod; } void nhap() { int n; bool te = true; cin >> n; vector<int> a(n + 1), b(n + 1); for (int i = 1; i <= n; i++) { cin >> a[i] >> b[i]; } if(te==true) { set<int>s(a.begin(), a.end()); for (int i = 0; i <= n; i++) s.insert(b[i] + 1); vector<int> v(s.begin(), s.end()); vector<vector<ll>> dp(n + 1, vector<ll>(v.size(), 0)); dp[0][0] = 1; for (int i = 1; i <= n; i++) { dp[i] = dp[i - 1]; ll sum = 0; for (int j = 0; j < v.size() - 1; j++) { if (a[i] <= v[j] && v[j] <= b[i]) { upd(dp[i][j], (sum * 1ll * (v[j + 1] - v[j])) % mod); } upd(sum, dp[i - 1][j]); } } ll ans = 0; for (int j = 1; j < v.size(); j++) upd(ans, dp[n][j]); cout << ans ; } return ; } int main() { fastio(); //inti(); nhap(); }

Compilation message (stderr)

boat.cpp: In function 'void nhap()':
boat.cpp:86:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   86 |   for (int j = 0; j < v.size() - 1; j++)
      |                   ~~^~~~~~~~~~~~~~
boat.cpp:96:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   96 |  for (int j = 1; j < v.size(); j++) upd(ans, dp[n][j]);
      |                  ~~^~~~~~~~~~
boat.cpp: In function 'void inti()':
boat.cpp:60:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   60 |         freopen(task".inp","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
boat.cpp:61:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   61 |         freopen(task".out","w",stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...