Submission #1120112

#TimeUsernameProblemLanguageResultExecution timeMemory
112011212345678Misspelling (JOI22_misspelling)C++17
28 / 100
46 ms2040 KiB
#include <bits/stdc++.h> using namespace std; const int nx=2e3+5, kx=26, mod=1e9+7; int n, m, a, b, dp[nx][kx], res, cu[nx], cd[nx]; vector<int> up[nx], dn[nx]; int main() { cin.tie(NULL)->sync_with_stdio(false); cin>>n>>m; for (int i=1; i<=m; i++) { cin>>a>>b; if (a<b) dn[a+1].push_back(b); else up[b+1].push_back(a); } for (int i=n; i>=1; i--) { for (int c=0; c<26; c++) { dp[i][c]=1; for (int j=i+1; j<=n; j++) { if (!cu[j]) { for (int d=0; d<c; d++) { dp[i][c]=(dp[i][c]+dp[j][d])%mod; } } if (!cd[j]) { for (int d=c+1; d<26; d++) { dp[i][c]=(dp[i][c]+dp[j][d])%mod; } } } //cout<<"debug "<<i<<' '<<c<<' '<<dp[i][c]<<'\n'; } for (auto x:up[i]) for (int j=i; j<=x; j++) cu[j]=1; for (auto x:dn[i]) for (int j=i; j<=x; j++) cd[j]=1; } for (int c=0; c<26; c++) res=(res+dp[1][c])%mod; cout<<res; }
#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...