제출 #839188

#제출 시각아이디문제언어결과실행 시간메모리
839188guagua0407캥거루 (CEOI16_kangaroo)C++17
6 / 100
1 ms468 KiB
//#pragma GCC optimize("O3") #include <bits/stdc++.h> using namespace std; #define ll long long #define pii pair<int,int> #define f first #define s second #define all(x) x.begin(),x.end() #define _ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); void setIO(string s) { freopen((s + ".in").c_str(), "r", stdin); freopen((s + ".out").c_str(), "w", stdout); } const int mxn=2005; const int mod=1e9+7; ll dp[mxn][mxn]; int cnt=0; int main() {_ int n,st,en; cin>>n>>st>>en; if(st>en) swap(st,en); dp[1][1]=1; if(1==st) cnt++; for(int i=1;i<n;i++){ if(i+1==st){ // new for(int j=1;j<=i;j++){ dp[i+1][j+1]=(dp[i+1][j+1]+dp[i][j])%mod; } // continue for(int j=1;j<=i;j++){ dp[i+1][j]=(dp[i+1][j]+dp[i][j]*j)%mod; } cnt++; } else if(i+1==en){ // new for(int j=1;j<=i;j++){ dp[i+1][j+1]=(dp[i+1][j+1]+dp[i][j])%mod; } // continue for(int j=1;j<=i;j++){ dp[i+1][j]=(dp[i+1][j]+dp[i][j]*(j-1+(i==n-1 and j==1)))%mod; } cnt++; } else{ // new for(int j=1;j<=i;j++){ dp[i+1][j+1]=(dp[i+1][j+1]+dp[i][j])%mod; } // combine for(int j=1;j<=i;j++){ dp[i+1][j-1]=(dp[i+1][j-1]+dp[i][j]*(j*(j-1)-(j-1)*cnt+(cnt==2)))%mod; } } } cout<<dp[n][1]<<'\n'; return 0; } //maybe its multiset not set

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

kangaroo.cpp: In function 'void setIO(std::string)':
kangaroo.cpp:12:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |     freopen((s + ".in").c_str(), "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
kangaroo.cpp:13:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |     freopen((s + ".out").c_str(), "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...