Submission #719096

#TimeUsernameProblemLanguageResultExecution timeMemory
719096Abrar_Al_SamitMisspelling (JOI22_misspelling)C++17
28 / 100
1002 ms1048576 KiB
#include<bits/stdc++.h> using namespace std; const int nax = 203; const int mod = 1e9 + 7; int n, m; int dp[nax][nax][nax][26]; int a[nax], b[nax]; int tp1[nax], tp2[nax]; int add(int a, int b) { a += b; if(a >= mod) a -= mod; return a; } int solve(int i, int j, int k, int pr) { if(i > n) return 1; if(j < i) j = 0; if(k < i) k = 0; int &ret = dp[i][j][k][pr]; if(ret!=-1) return ret; ret = 0; if(j+k==0) { for(int cr=0; cr<26; ++cr) { ret = add(ret, solve(i+1, tp1[i], tp2[i], cr)); } } else if(j && k) { ret = solve(i+1, max(j, tp1[i]), max(k, tp2[i]), pr); } else if(j) { ret = solve(i+1, max(j, tp1[i]), max(k, tp2[i]), pr); for(int cr=0; cr<pr; ++cr) { ret = add(ret, solve(i+1, tp1[i], tp2[i], cr)); } } else { ret = solve(i+1, max(j, tp1[i]), max(k, tp2[i]), pr); for(int cr=pr+1; cr<26; ++cr) { ret = add(ret, solve(i+1, tp1[i], tp2[i], cr)); } } return ret; } void PlayGround() { cin>>n>>m; for(int i=1; i<=m; ++i) { cin>>a[i]>>b[i]; if(a[i] < b[i]) { tp1[a[i]] = max(tp1[a[i]], b[i]); } else { tp2[b[i]] = max(tp2[b[i]], a[i]); } } memset(dp, -1, sizeof dp); cout<<solve(1, 0, 0, 0)<<'\n'; // cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); PlayGround(); return 0; }
#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...