제출 #255699

#제출 시각아이디문제언어결과실행 시간메모리
255699MercenaryBoat (APIO16_boat)C++14
100 / 100
581 ms4476 KiB
#include<bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/trie_policy.hpp> #define pb push_back #define mp make_pair #define taskname "A" using namespace std; using namespace __gnu_pbds; typedef long long ll; typedef double ld; typedef pair<int,int> ii; typedef tree <ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; const int maxn = 500 + 5; const int mod = 1e9 + 7; int n , a[maxn] , b[maxn]; int dp[maxn][maxn * 2]; int c[maxn * 2][maxn]; vector<int> val; int Pow(int i , int j){ if(j == 0)return 1; int r = Pow(i , j / 2); if(j & 1)return (ll)r * r % mod * i % mod; return (ll)r * r % mod; } int r[maxn]; 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 = 1 ; i <= n ; ++i){ cin >> a[i] >> b[i];--a[i]; val.pb(a[i]);val.pb(b[i]); r[i] = Pow(i , mod - 2); } sort(val.begin(),val.end());val.erase(unique(val.begin(),val.end()),val.end()); for(int i = 0 ; i < val.size() ; ++i){ dp[0][i] = 1; if(i > 0){ int len = val[i] - val[i - 1]; c[i][0] = 1; for(int j = 1 ; j <= n ; ++j){ c[i][j] = (ll)c[i][j - 1] * (len + j - 1) % mod * r[j] % mod; } } } for(int i = 1 ; i <= n ; ++i){ dp[i][0] = 1; for(int j = 1 ; j < val.size() ; ++j){ int sum = 0; dp[i][j] = dp[i][j - 1]; for(int k = i ; k >= 1 ; --k){ if(a[k] < val[j] && val[j] <= b[k]){ dp[i][j] = (dp[i][j] + (ll)dp[k - 1][j - 1] * c[j][++sum]) %mod; } } // cout << dp[i][j] << " "; } // cout << endl; } cout << dp[n][val.size() - 1] - 1; }

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

boat.cpp: In function 'int main()':
boat.cpp:46:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0 ; i < val.size() ; ++i){
                     ~~^~~~~~~~~~~~
boat.cpp:58:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int j = 1 ; j < val.size() ; ++j){
                         ~~^~~~~~~~~~~~
boat.cpp:36:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   freopen(taskname".INP", "r",stdin);
   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
boat.cpp:37:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   freopen(taskname".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...