제출 #50352

#제출 시각아이디문제언어결과실행 시간메모리
50352dualityBoat (APIO16_boat)C++11
100 / 100
877 ms5256 KiB
#include <bits/stdc++.h> using namespace std; // basic debugging macros int __i__,__j__; #define printLine(l) for(__i__=0;__i__<l;__i__++){cout<<"-";}cout<<endl #define printLine2(l,c) for(__i__=0;__i__<l;__i__++){cout<<c;}cout<<endl #define printVar(n) cout<<#n<<": "<<n<<endl #define printArr(a,l) cout<<#a<<": ";for(__i__=0;__i__<l;__i__++){cout<<a[__i__]<<" ";}cout<<endl #define print2dArr(a,r,c) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<a[__i__][__j__]<<" ";}cout<<endl;} #define print2dArr2(a,r,c,l) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<setw(l)<<setfill(' ')<<a[__i__][__j__]<<" ";}cout<<endl;} // advanced debugging class // debug 1,2,'A',"test"; class _Debug { public: template<typename T> _Debug& operator,(T val) { cout << val << endl; return *this; } }; #define debug _Debug(), // define #define MAX_VAL 999999999 #define MAX_VAL_2 999999999999999999LL #define EPS 1e-6 // typedef typedef unsigned int UI; typedef long long int LLI; typedef unsigned long long int ULLI; typedef unsigned short int US; typedef pair<int,int> pii; typedef pair<LLI,LLI> plli; typedef vector<int> vi; typedef vector<LLI> vlli; typedef vector<pii> vpii; typedef vector<plli> vplli; // ---------- END OF TEMPLATE ---------- #define MOD 1000000007 int a[500],b[500]; vi l; LLI inv[501]; LLI dp[500][1000]; int main() { int i; int N; scanf("%d",&N); for (i = 0; i < N; i++) scanf("%d %d",&a[i],&b[i]),b[i]++,l.push_back(a[i]),l.push_back(b[i]); l.push_back(-1); sort(l.begin(),l.end()); l.resize(unique(l.begin(),l.end())-l.begin()); int j,k; int s = 0,x; LLI w; for (i = 1; i <= N; i++) { int e = MOD-2; LLI r = 1,b = i; while (e > 0) { if (e & 1) r *= b,r %= MOD; e >>= 1; b *= b,b %= MOD; } inv[i] = r; } for (i = 0; i < N; i++) { for (j = 1; j < (l.size()-1); j++) { w = 1,x = 0; dp[i][j] = dp[i][j-1]; for (k = i; k >= 0; k--) { if ((l[j] >= a[k]) && (l[j+1] <= b[k])) { w *= l[j+1]-l[j]+x,w %= MOD; w *= inv[x+1],w %= MOD; x++; } else if (k == i) break; if (k == 0) dp[i][j] += w; else dp[i][j] += w*dp[k-1][j-1]; dp[i][j] %= MOD; } } s += dp[i][l.size()-2],s %= MOD; } printf("%d\n",s); return 0; }

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

boat.cpp: In function 'int main()':
boat.cpp:72:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (j = 1; j < (l.size()-1); j++) {
                     ~~^~~~~~~~~~~~~~
boat.cpp:52:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&N);
     ~~~~~^~~~~~~~~
boat.cpp:53:80: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for (i = 0; i < N; i++) scanf("%d %d",&a[i],&b[i]),b[i]++,l.push_back(a[i]),l.push_back(b[i]);
                             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...