Submission #815054

#TimeUsernameProblemLanguageResultExecution timeMemory
815054waldiMisspelling (JOI22_misspelling)C++17
28 / 100
4101 ms72748 KiB
#include<bits/stdc++.h> #define FOR(i,p,k) for(int i=(p);i<=(k);++i) #define REP(i,n) FOR(i,0,(n)-1) #define pii pair<int, int> #define fi first #define se second #define mod 1000000007 #define A 26 typedef long long ll; using namespace std; struct modular{ int a; modular(int x = 0){a = x;} modular operator+(modular t){return {(a+t.a)%mod};} modular operator-(modular t){return {(a-t.a+mod)%mod};} void operator+=(modular t){a = (a+t.a)%mod;} }; int main(){ int n, m; scanf("%d%d", &n, &m); vector<pii> wym; while(m--){ int a, b; scanf("%d%d", &a, &b); wym.emplace_back(a, b); } vector<vector<modular>> dp(n+1, vector<modular>(A, 0)); REP(lit, A) dp[1][lit] = 1; FOR(pref, 1, n-1) REP(lit, A){ modular t = dp[pref][lit]; int dol = 0; for(pii i : wym){ if(i.fi < i.se) continue; int p = min(i.fi, i.se); int k = max(i.fi, i.se); if(p <= pref && pref < k) dol = max(dol, p); } int gora = 0; for(pii i : wym){ if(i.fi > i.se) continue; int p = min(i.fi, i.se); int k = max(i.fi, i.se); if(p <= pref && pref < k) gora = max(gora, p); } REP(nowa, A){ int ogr = 0; if(nowa < lit) ogr = dol; if(nowa > lit) ogr = gora; dp[pref+1][nowa] += t-dp[ogr][lit]; } } modular wyn = 0; REP(lit, A) wyn += dp[n][lit]; printf("%d", wyn.a); }

Compilation message (stderr)

misspelling.cpp: In function 'int main()':
misspelling.cpp:22:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |  scanf("%d%d", &n, &m);
      |  ~~~~~^~~~~~~~~~~~~~~~
misspelling.cpp:26:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |   scanf("%d%d", &a, &b);
      |   ~~~~~^~~~~~~~~~~~~~~~
#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...