Submission #901670

#TimeUsernameProblemLanguageResultExecution timeMemory
901670alexander707070Misspelling (JOI22_misspelling)C++14
28 / 100
4042 ms8408 KiB
#include<bits/stdc++.h> #define MAXN 20007 using namespace std; const int mod=1e9+7; int n,m,a,b,ans; int dp[MAXN][30]; int es[MAXN],es2[MAXN]; bool bad[MAXN],bad2[MAXN]; int pt,pt2; int sum[30],sum2[30]; void calc_dp(){ pt=pt2=n+1; for(int pos=n;pos>=1;pos--){ for(int f=pos+1;f<=es[pos];f++){ for(int letter=0;letter<26;letter++){ if(!bad[f])sum[letter]-=dp[f][letter]; sum[letter]+=mod; sum[letter]%=mod; } bad[f]=true; } for(int f=pos+1;f<=es2[pos];f++){ for(int letter=0;letter<26;letter++){ if(!bad2[f])sum2[letter]-=dp[f][letter]; sum2[letter]+=mod; sum2[letter]%=mod; } bad2[f]=true; } if(es[pos]>=pos+1)pt=pos+1; if(es2[pos]>=pos+1)pt2=pos+1; for(int letter=0;letter<26;letter++){ dp[pos][letter]=1; for(int nxtletter=0;nxtletter<26;nxtletter++){ if(nxtletter==letter)continue; if(nxtletter<letter)dp[pos][letter]+=sum[nxtletter]; if(nxtletter>letter)dp[pos][letter]+=sum2[nxtletter]; dp[pos][letter]%=mod; } } for(int letter=0;letter<26;letter++){ sum[letter]+=dp[pos][letter]; sum[letter]%=mod; sum2[letter]+=dp[pos][letter]; sum2[letter]%=mod; } } } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin>>n>>m; for(int i=1;i<=m;i++){ cin>>a>>b; if(a<b){ es[a]=max(es[a],b); }else{ es2[b]=max(es2[b],a); } } calc_dp(); for(int i=0;i<26;i++){ ans+=dp[1][i]; ans%=mod; } cout<<ans<<"\n"; return 0; }

Compilation message (stderr)

misspelling.cpp: In function 'void calc_dp()':
misspelling.cpp:25:17: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   25 |                 if(!bad[f])sum[letter]-=dp[f][letter]; sum[letter]+=mod; sum[letter]%=mod;
      |                 ^~
misspelling.cpp:25:56: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   25 |                 if(!bad[f])sum[letter]-=dp[f][letter]; sum[letter]+=mod; sum[letter]%=mod;
      |                                                        ^~~
misspelling.cpp:32:17: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   32 |                 if(!bad2[f])sum2[letter]-=dp[f][letter]; sum2[letter]+=mod; sum2[letter]%=mod;
      |                 ^~
misspelling.cpp:32:58: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   32 |                 if(!bad2[f])sum2[letter]-=dp[f][letter]; sum2[letter]+=mod; sum2[letter]%=mod;
      |                                                          ^~~~
#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...