Submission #1310133

#TimeUsernameProblemLanguageResultExecution timeMemory
1310133thuhienneMisspelling (JOI22_misspelling)C++20
28 / 100
60 ms4676 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; #define thuhien "" #define re exit(0); const int mod = 1e9 + 7; const int maxn = 2009; int n,m; pair <int,int> cond[maxn]; int dp[maxn][27]; //dp i j: so cach build [i,n] thoa man dieu kien trong m cai tren int maxarr[maxn][maxn][2]; int main() { // ios_base::sync_with_stdio(0); // cin.tie(nullptr); if (fopen(thuhien".inp","r")) { freopen(thuhien".inp","r",stdin); freopen(thuhien".out","w",stdout); } cin >> n >> m; for (int i = 1;i <= m;i++) { int a,b;cin >> a >> b; cond[i] = {a,b}; int l = min(a,b),r = max(a,b); maxarr[l][l][a < b] = max(maxarr[l][l][a < b],r); } for (int i = n;i >= 1;i--) { for (int j = i + 1;j <= n;j++) { maxarr[i][j][0] = max(maxarr[i][j - 1][0],maxarr[j][j][0]); maxarr[i][j][1] = max(maxarr[i][j - 1][1],maxarr[j][j][1]); } } for (int i = n;i >= 1;i--) { for (int j = 0;j <= 'z' - 'a';j++) { dp[i][j] = 1; for (int k = i;k <= n;k++) { int less = maxarr[i][k][0]; int greater = maxarr[i][k][1]; if (less > k && greater > k) continue; else if (less <= k && greater <= k) { for (int h = 0;h <= 'z' - 'a';h++) if (j != h) { dp[i][j] = (dp[i][j] + dp[k + 1][h]) % mod; } } else { for (int h = 0;h <= 'z' - 'a';h++) if ((less > k && j < h) || (greater > k && j > h)) { dp[i][j] = (dp[i][j] + dp[k + 1][h]) % mod; } } } } } int res = 0; for (int h = 0;h <= 'z' - 'a';h++) res = (res + dp[1][h]) % mod; cout << res; }

Compilation message (stderr)

misspelling.cpp: In function 'int main()':
misspelling.cpp:24:19: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |            freopen(thuhien".inp","r",stdin);
      |            ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
misspelling.cpp:25:19: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   25 |            freopen(thuhien".out","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...
#Verdict Execution timeMemoryGrader output
Fetching results...