Submission #46161316


Source Code Expand

#include<bits/stdc++.h>
#define LL long long
#define DB double
#define MOD 1000000007
#define ls(x) (x << 1)
#define rs(x) (x << 1 | 1)
#define lowbit(x) ((-x) & x)
#define MP make_pair
#define VI vector<int>
#define VL vector<LL>
#define VII VI::iterator
#define VLI VL::iterator
#define all(x) x.begin(), x.end()
#define EB emplace_back
#define PII pair<int, int>
#define SI set<int>
#define SII SI::iterator
#define fi first
#define se second
using namespace std;
template<typename T> void chkmn(T &a, const T &b) { (a > b) && (a = b); }
template<typename T> void chkmx(T &a, const T &b) { (a < b) && (a = b); }
void Inc(int &a, const int &b) { ((a += b) >= MOD) && (a -= MOD); }
void Dec(int &a, const int &b) { ((a -= b) < 0) && (a += MOD); }
void Mul(int &a, const int &b) { a = 1LL * a * b % MOD; }
void Sqr(int &a) { a = 1LL * a * a % MOD; }
int inc(const int &a, const int &b) { return (a + b >= MOD) ? a + b - MOD : a + b; }
int dec(const int &a, const int &b) { return (a - b < 0) ? a - b + MOD : a - b; }
int mul(const int &a, const int &b) { return 1LL * a * b % MOD; }
int sqr(const int &a) { return 1LL * a * a % MOD; }
int qwqmi(int x, int k = MOD - 2)
{
	int res = 1;
	while(k)
	{
		if(k & 1) Mul(res, x);
		k >>= 1, Sqr(x);
	}
	return res;
}
const int N = 605;
int n, m;
int vis[N];
int c[N][N];
int f[N][N], g[N], ans;
int main()
{
	scanf("%d %d", &n, &m); n <<= 1;
	for(int i = 1; i <= m; ++i)
	{
		int x, y;
		scanf("%d %d", &x, &y);
		vis[x] = y, vis[y] = x;
	}
	for(int l = 1; l <= n; ++l)
		for(int r = l; r <= n; ++r)
			for(int i = l; i <= r; ++i)
				c[l][r] += (vis[i] == 0);
	g[0] = 1;
	for(int i = 2; i <= n; i += 2)
		g[i] = mul(g[i - 2], i - 1);
	
	for(int len = 2; len <= n; ++len)
		for(int l = 1; l + len - 1 <= n; ++l)
		{
			int r = l + len - 1;
			if(c[l][r] & 1) continue;
			bool flag = 1;
			for(int i = l; i <= r && flag; ++i)
				if(vis[i] && (vis[i] < l || vis[i] > r))
					flag = 0;
			if(!flag) continue;
			int w = g[c[l][r]];
			for(int i = l; i < r; ++i)
				Dec(w, mul(f[l][i], g[c[i + 1][r]]));
			f[l][r] = w;
			Inc(ans, mul(f[l][r], g[c[1][l - 1] + c[r + 1][n]]));
		}
	printf("%d\n", ans);
	return 0;
}

Submission Info

Submission Time
Task D - Chords
User Schucking_Sattin
Language C++ 20 (gcc 12.2)
Score 900
Code Size 2242 Byte
Status AC
Exec Time 70 ms
Memory 6700 KiB

Compile Error

Main.cpp: In function ‘int main()’:
Main.cpp:48:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   48 |         scanf("%d %d", &n, &m); n <<= 1;
      |         ~~~~~^~~~~~~~~~~~~~~~~
Main.cpp:52:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   52 |                 scanf("%d %d", &x, &y);
      |                 ~~~~~^~~~~~~~~~~~~~~~~

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 900 / 900
Status
AC × 3
AC × 26
Set Name Test Cases
Sample sample-01.txt, sample-02.txt, sample-03.txt
All sample-01.txt, sample-02.txt, sample-03.txt, sample-01.txt, sample-02.txt, sample-03.txt, subtask01-01.txt, subtask01-02.txt, subtask01-03.txt, subtask01-04.txt, subtask01-05.txt, subtask01-06.txt, subtask01-07.txt, subtask01-08.txt, subtask01-09.txt, subtask01-10.txt, subtask01-11.txt, subtask01-12.txt, subtask01-13.txt, subtask01-14.txt, subtask01-15.txt, subtask01-16.txt, subtask01-17.txt, subtask01-18.txt, subtask01-19.txt, subtask01-20.txt
Case Name Status Exec Time Memory
sample-01.txt AC 1 ms 3724 KiB
sample-02.txt AC 1 ms 3784 KiB
sample-03.txt AC 1 ms 4008 KiB
subtask01-01.txt AC 1 ms 3628 KiB
subtask01-02.txt AC 52 ms 6392 KiB
subtask01-03.txt AC 38 ms 6416 KiB
subtask01-04.txt AC 2 ms 4380 KiB
subtask01-05.txt AC 1 ms 4172 KiB
subtask01-06.txt AC 25 ms 6040 KiB
subtask01-07.txt AC 6 ms 5308 KiB
subtask01-08.txt AC 4 ms 4752 KiB
subtask01-09.txt AC 70 ms 6700 KiB
subtask01-10.txt AC 32 ms 6624 KiB
subtask01-11.txt AC 24 ms 6408 KiB
subtask01-12.txt AC 21 ms 5956 KiB
subtask01-13.txt AC 21 ms 5620 KiB
subtask01-14.txt AC 19 ms 5128 KiB
subtask01-15.txt AC 25 ms 6612 KiB
subtask01-16.txt AC 26 ms 6608 KiB
subtask01-17.txt AC 31 ms 6544 KiB
subtask01-18.txt AC 25 ms 5952 KiB
subtask01-19.txt AC 33 ms 6016 KiB
subtask01-20.txt AC 55 ms 6512 KiB