# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
113644 | 2019-05-27T10:48:53 Z | Mercenary | Boat (APIO16_boat) | C++14 | 4 ms | 640 KB |
#include<bits/stdc++.h> using namespace std; #define taskname "A" #define pb push_back #define mp make_pair #ifndef LOCAL #define cerr if(0)cout #endif typedef long double ld; typedef long long ll; typedef pair<int,int> ii; const int maxn = 1e3 + 5; const int mod = 1e9 + 7; int Pow(int a , int b){ if(b == 0)return 1; int r = Pow(a , b / 2); if(b & 1)return (ll)r * r % mod * a % mod; return (ll)r * r % mod; } const int div6 = Pow(6,mod-2); int dp[2][maxn]; vector<int> v; int n , a[maxn] , b[maxn]; int cal(int dis){ return ((ll)(dis + 1) * (dis + 1) % mod * dis % mod - (ll)dis * (dis + 1) % mod * (2 * dis + 1) % mod * div6 % mod + mod) % mod; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); if(fopen(taskname".INP","r")){ freopen(taskname".INP", "r",stdin); freopen(taskname".OUT", "w",stdout); } cin >> n; for(int i = 0 ; i < n ; ++i){ cin >> a[i] >> b[i]; v.pb(a[i]);v.pb(b[i]); } sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end()); v.pb(v.back() + 1); bool bit = 0; for(int i = 0 ; i < n ; ++i){ bit ^= 1; int from = lower_bound(v.begin(),v.end(),a[i]) - v.begin(); int to = lower_bound(v.begin(),v.end(),b[i]) - v.begin(); int now = 1; for(int j = 0 ; j < v.size() ; ++j){ if(j)now += cal(v[j] - v[j - 1]) * dp[bit ^ 1][j - 1]; if(from <= j && j <= to)dp[bit][j] = dp[bit ^ 1][j] + now; else dp[i][j] = dp[bit ^ 1][j]; } } int now = 1; for(int j = 0 ; j < v.size() ; ++j){ if(j)now += cal(v[j] - v[j - 1]) * dp[bit ^ 1][j - 1]; } cout << now; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 4 ms | 640 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 4 ms | 640 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 2 ms | 640 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 4 ms | 640 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |