Submission #198882

#TimeUsernameProblemLanguageResultExecution timeMemory
198882arnold518Linear Garden (IOI08_linear_garden)C++14
0 / 100
60 ms65540 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const int MAXN = 1e6; int N, M, dp[MAXN+1][3][3][5]; int solve(int pos, int a, int b, int c) { if(pos==N+1) return 1; int &ret=dp[pos][-a][b][c+2]; if(ret!=-1) return ret; ret=0; if(max(b, c+1)-a<=2) ret+=solve(pos+1, a, max(b, c+1), c+1); if(b-min(a, c-1)<=2) ret+=solve(pos+1, min(a, c-1), b, c-1); ret%=M; return ret; } int main() { int i, j; scanf("%d%d", &N, &M); memset(dp, -1, sizeof(dp)); printf("%d", solve(1, 0, 0, 0)); }

Compilation message (stderr)

linear_garden.cpp: In function 'int main()':
linear_garden.cpp:27:6: warning: unused variable 'i' [-Wunused-variable]
  int i, j;
      ^
linear_garden.cpp:27:9: warning: unused variable 'j' [-Wunused-variable]
  int i, j;
         ^
linear_garden.cpp:29:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d", &N, &M);
  ~~~~~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...