Submission #1328336

#TimeUsernameProblemLanguageResultExecution timeMemory
1328336SmuggingSpunMisspelling (JOI22_misspelling)C++20
8 / 100
1 ms344 KiB
#include<bits/stdc++.h>
#define taskname "C"
using namespace std;
const int mod = 1e9 + 7;
template<class T>void maximize(T& a, T b){
  if(a < b){
    a = b;
  }
}
void add(int& a, int b){
  if((a += b) >= mod){
    a -= mod;
  }
}
int n, m;
namespace sub1{
  const int lim = 11;
  int f[lim][lim][lim][26];
  vector<int>event[lim];
  int dp(int p, int lar, int sma, int pre){
    if(p > n){
      return 1;
    }
    int& ans = f[p][lar][sma][pre];
    if(ans != -1){
      return ans;
    }
    int nlar = 0, nsma = 0;
    for(int& i : event[p]){
      if(i > 0){
        maximize(nlar, i);
      }
      else{
        maximize(nsma, -i);
      }
    }
    ans = dp(p + 1, max(lar, nlar), max(sma, nsma), pre);
    if(p > sma){
      for(int i = 0; i < pre; i++){
        add(ans, dp(p + 1, nlar, nsma, i));
      }
    }
    if(p > lar){
      for(int i = pre + 1; i < 26; i++){
        add(ans, dp(p + 1, nlar, nsma, i));
      }
    }
    return ans;
  }
  void solve(){
    for(int _ = 0; _ < m; _++){
      int a, b;
      cin >> a >> b;
      if(a < b){
        event[a].push_back(b);
      }
      else{
        event[b].push_back(-a);
      }
    }
    memset(f, -1, sizeof(f));
    int ans = 0, lar = 0, sma = 0;
    for(int& i : event[1]){
      if(i > 0){
        maximize(lar, i);
      }
      else{
        maximize(sma, -i);
      }
    }
    for(int i = 0; i < 26; i++){
      add(ans, dp(2, lar, sma, i));
    }
    cout << ans;
  }
}
int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	if(fopen(taskname".inp", "r")){
		freopen(taskname".inp", "r", stdin);
	}
  cin >> n >> m;
  if(n <= 10){
    sub1::solve();
  }
  else{
  }
}

Compilation message (stderr)

misspelling.cpp: In function 'int main()':
misspelling.cpp:80:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   80 |                 freopen(taskname".inp", "r", stdin);
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
#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...