제출 #203605

#제출 시각아이디문제언어결과실행 시간메모리
203605stefdasca캥거루 (CEOI16_kangaroo)C++14
51 / 100
521 ms1400 KiB
#include<bits/stdc++.h> #define mod 1000000007 using namespace std; int n, a, b; int add(int a, int b) { int x = a+b; if(x >= mod) x -= mod; if(x < 0) x += mod; return x; } int dp[2][2][202][202]; int main() { cin >> n >> a >> b; for(int i = 1; i <= n; ++i) if(i != a && i != b) dp[0][(a < i)][i - 1 - (a < i)][b - (a < b) - (i < b)] = 1; if(n == 2) { cout << 1; return 0; } int ans = 0; for(int sum = n-2; sum >= 1; --sum) { for(int i = 0; i <= sum; ++i) for(int pos = 1; pos <= sum; ++pos) { int smaller = i; int bigger = sum - i; if(!dp[0][0][smaller][pos] && !dp[0][1][smaller][pos]) continue; // cout << sum << '\n'; // cout << smaller << " " << bigger << " " << pos << '\n'; // cout << dp[0][smaller][bigger][pos] << " " << dp[1][smaller][bigger][pos] << '\n'; if(sum == 1) { if(smaller) ans = add(ans, dp[0][1][smaller][1]); else ans = add(ans, dp[0][0][smaller][1]); } else for(int relpos = 1; relpos <= sum; ++relpos) { if(pos == relpos) continue; if(relpos <= smaller) dp[1][0][relpos - 1][pos - (relpos < pos)] = add(dp[1][0][relpos - 1][pos - (relpos < pos)], dp[0][1][smaller][pos]); else dp[1][1][relpos - 1][pos - (relpos < pos)] = add(dp[1][1][relpos - 1][pos - (relpos < pos)], dp[0][0][smaller][pos]); } } memcpy(dp[0], dp[1], sizeof(dp[1])); memset(dp[1], 0, sizeof(dp[1])); } cout << ans; return 0; }

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

kangaroo.cpp: In function 'int main()':
kangaroo.cpp:33:21: warning: unused variable 'bigger' [-Wunused-variable]
                 int bigger = sum - 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...