Submission #936552

# Submission time Handle Problem Language Result Execution time Memory
936552 2024-03-02T07:26:10 Z TAhmed33 Misspelling (JOI22_misspelling) C++
0 / 100
12 ms 76636 KB
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
int add (int a, int b) {
	a += b; if (a >= MOD) a -= MOD;
	return a;
}
int sub (int a, int b) {
	a -= b; if (a < 0) a += MOD;
	return a;
}
int mul (int a, int b) {
	return (a * 1ll * b) % MOD;
}
const int MAXN = 5e5 + 25;
int dp[MAXN][27];
int n, m;
vector <int> type1[MAXN];
vector <int> type2[MAXN];
int ans (int pos, int c) {
	int &ret = dp[pos][c];
	if (ret != -1) return ret;
	if (pos == 1) return ret = 1;
	ret = 0;
	for (int j = 0; j < c; j++) {
		bool flag = 1;
		for (int i = pos - 1; i >= 1; i--) {
			for (auto k : type2[i - 1]) {
				flag &= (pos > k);
			}	
			if (flag) ret = add(ret, ans(i, j));
		}
	}
	for (int j = c + 1; j < 26; j++) {
		bool flag = 1;
		for (int i = pos - 1; i >= 1; i--) {
			for (auto k : type2[i - 1]) {
				flag &= (pos > k);
			}	
			if (flag) ret = add(ret, ans(i, j));
		}
	}
	return ret;
}
int main () {
	memset(dp, -1, sizeof(dp));
	cin >> n >> m;
	for (int i = 1; i <= m; i++) {
		int a, b;
		cin >> a >> b;
		int l = min(a, b), r = max(a, b);
		if (a > b) {
			type1[l - 1].push_back(r);
		} else {
			type2[l - 1].push_back(r);
		}
	}
	int sum = 0;
	for (int i = 0; i < 26; i++) {
		for (int j = 1; j <= n; j++) {
			sum = add(sum, ans(j, i));
		}
	}
	cout << sum << '\n';
}
# Verdict Execution time Memory Grader output
1 Incorrect 12 ms 76636 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 12 ms 76636 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 12 ms 76636 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 12 ms 76636 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 12 ms 76636 KB Output isn't correct
2 Halted 0 ms 0 KB -