Submission #814798

#TimeUsernameProblemLanguageResultExecution timeMemory
814798waldiMisspelling (JOI22_misspelling)C++17
8 / 100
4051 ms1048576 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 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};} 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<vector<modular>>> dp(n+1, vector<vector<modular>>(n+1, vector<modular>(26, 0))); REP(lit, 26) dp[1][1][lit] = 1; FOR(poc, 1, n) FOR(kon, poc, n-1) REP(lit, 26){ modular t = dp[poc][kon][lit]; dp[poc][kon+1][lit] += t; bool dol = 1, gora = 1; for(pii i : wym){ int p = min(i.fi, i.se); int k = max(i.fi, i.se); if(poc<=p&&p<=kon && kon<k){ if(i.se<i.fi) dol = 0; if(i.fi<i.se) gora = 0; } } REP(nowa, 26){ if(nowa < lit && dol) dp[kon+1][kon+1][nowa] += t; if(nowa > lit && gora) dp[kon+1][kon+1][nowa] += t; } } modular wyn = 0ll; FOR(poc, 1, n) REP(lit, 26) wyn += dp[poc][n][lit]; printf("%d", wyn.a); }

Compilation message (stderr)

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