Submission #547771

#TimeUsernameProblemLanguageResultExecution timeMemory
547771nonsensenonsense1Misspelling (JOI22_misspelling)C++17
28 / 100
4017 ms7036 KiB
#include <cstdio>
#include <utility>
#include <algorithm>

const int md = 1000000007;

inline int add(int a, int b) {
	a += b;
	if (a >= md) a -= md;
	return a;
}
inline int mul(int a, int b) {
	return (long long)a * b % md;
}

const int A = 26;
const int N = 500000;
int n, m, d[N][A];
bool u[2][N];
std::pair<std::pair<int, int>, bool> a[N];

int main() {
	scanf("%d%d", &n, &m);
	for (int i = 0; i < m; ++i) {
		int x, y;
		scanf("%d%d", &x, &y);
		--x;
		--y;
		if (x < y) a[i] = std::make_pair(std::make_pair(x, y), 1);
		else a[i] = std::make_pair(std::make_pair(y, x), 0);
	}
	std::sort(a, a + m);
	for (int i = n - 1, j = m - 1; i >= 0; --i) {
		while (j >= 0 && a[j].first.first == i) {
			for (int k = i; k < a[j].first.second; ++k) u[a[j].second][k] = 1;
			--j;
		}
		for (int x = 0; x < A; ++x) {
			d[i][x] = 1;
			for (int k = i; k < n - 1; ++k) 
				for (int y = 0; y < A; ++y) 
					if (x < y && !u[1][k] || x > y && !u[0][k]) 
						d[i][x] = add(d[i][x], d[k + 1][y]);
		}
	}
	int ans = 0;
	for (int i = 0; i < A; ++i) ans = add(ans, d[0][i]);
	printf("%d\n", ans);
	return 0;
}

Compilation message (stderr)

misspelling.cpp: In function 'int main()':
misspelling.cpp:42:16: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   42 |      if (x < y && !u[1][k] || x > y && !u[0][k])
      |          ~~~~~~^~~~~~~~~~~
misspelling.cpp:23:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |  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", &x, &y);
      |   ~~~~~^~~~~~~~~~~~~~~~
#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...