Submission #163720

#TimeUsernameProblemLanguageResultExecution timeMemory
163720MvCKangaroo (CEOI16_kangaroo)C++11
0 / 100
2 ms376 KiB
#pragma GCC target("avx2") #pragma GCC optimization("O3") #pragma GCC optimization("unroll-loops") #include <bits/stdc++.h> #define rc(x) return cout<<x<<endl,0 #define pb push_back #define mkp make_pair #define in insert #define er erase #define fd find #define fr first #define sc second typedef long long ll; typedef long double ld; const ll INF=0x3f3f3f3f3f3f3f3f; const ll llinf=(1LL<<62); const int inf=(1<<30); const int nmax=2e2+50; const int mod=1e9+7; using namespace std; int f[nmax][nmax][2][nmax][2],n,cs,cf,t,k,i,j,rs; void ad(int &x,int y) { x+=y; if(x>=mod)x-=mod; } int main() { //freopen("sol.in","r",stdin); //freopen("sol.out","w",stdout); //mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0); cin>>n>>cs>>cf; f[1][0][0][0][0]=f[1][0][0][0][1]=f[1][0][1][0][0]=f[1][0][1][0][1]=1; for(t=1;t<n;t++) { // left occupied for(k=0;k<=min(t,cs-1);k++) { // left for(i=0;i<=cs-1-k+1;i++) { // --> for(j=1;j<i;j++) { ad(f[t+1][k+1][0][j][0],f[t][k][0][i][1]); //cout<<f[t][k][0][i][1]<<endl; } for(j=1;j<=n-cs-(t-k)+1;j++) { ad(f[t+1][k][1][j][0],f[t][k][0][i][1]); //cout<<f[t][k][0][i][1]<<endl; } // <-- for(j=i+1;j<=cs-1-k+1;j++) { ad(f[t+1][k+1][0][j][1],f[t][k][0][i][0]); //cout<<f[t][k][0][i][0]<<endl; } } // right for(i=0;i<=n-cs-(t-k)+1;i++) { // <-- for(j=1;j<i;j++) { ad(f[t+1][k][1][j][1],f[t][k][1][i][0]); //cout<<f[t][k][1][i][0]<<endl; } for(j=1;j<=cs-1-k+1;j++) { ad(f[t+1][k+1][0][j][1],f[t][k][1][i][0]); //cout<<f[t][k][1][i][0]<<endl; } // --> for(j=i+1;j<=n-cs-(t-k)+1;j++) { ad(f[t+1][k][1][j][0],f[t][k][1][i][1]); //cout<<f[t][k][1][i][1]<<endl; } } } } if(cf>cs)rs=(f[n][cs-1][1][cf-cs][0]+f[n][cs-1][1][cf-cs][1])%mod; else rs=(f[n][cs-1][0][cs-cf][0]+f[n][cs-1][0][cs-cf][1])%mod; cout<<rs<<endl; return 0; }

Compilation message (stderr)

kangaroo.cpp:2:0: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
 #pragma GCC optimization("O3")
 
kangaroo.cpp:3:0: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
 #pragma GCC optimization("unroll-loops")
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...