QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#686213#6410. Classical DP ProblembadmintonWA 1ms7808kbC++141.8kb2024-10-29 08:53:542024-10-29 08:53:55

Judging History

你现在查看的是最新测评结果

  • [2024-10-29 08:53:55]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:7808kb
  • [2024-10-29 08:53:54]
  • 提交

answer

#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair <ll,ll> pll;
typedef pair <int,int> pii;
typedef pair <int,pii> piii;

#define forr(_a,_b,_c) for(int _a = (_b); _a <= int (_c); ++_a)
#define ford(_a,_b,_c) for(int _a = (_b) + 1; _a --> int (_c);)
#define forf(_a,_b,_c) for(int _a = (_b); _a < int (_c); ++_a)
#define st first
#define nd second
#define pb push_back
#define mp make_pair
#define all(x) begin(x),end(x)
#define mask(i) (1LL << (i))
#define bit(x, i) (((x) >> (i)) & 1)
#define bp __builtin_popcountll
#define file "test"

template<class X, class Y>
	bool minz(X &x, const Y &y) {
		if (x > y) {
			x = y;
			return true;
		} return false;
	}
template<class X, class Y>
	bool maxz(X &x, const Y &y) {
		if (x < y) {
			x = y;
			return true;
		} return false;
	}

const int N = 5e5 + 5;
const ll oo = (ll) 1e16;
const ll mod = 1e9 + 7; // 998244353;

int n, m;
ll dp[N];

int calc(int *a){
	int k = a[m];

	forr (i, 0, k + 1) 
		dp[i] = 0;
	
	dp[0] = 1;

	forr (i, 0, m){
		ford (j, min(i + 1, k), 1){
			dp[j] = (((k - j + 1) * dp[j - 1] + (a[i] - k + j) * dp[j]) % mod);
		}
		dp[0] = (dp[0] * (a[i] - k)) % mod;
	}

	return dp[k];
}

int a[N], b[N];

void solve (){
	cin >> n;

	forr (i, 1, n){
		cin >> a[i];
		b[a[i]]++;
	}

	reverse(a + 1, a + 1 + n);

	
	m = 1;

	ford (i, n, 1){
		b[i] += b[i + 1];
	}

	while (a[m] > m){
		m++;
	}

	ll uwu = 1;

	forr (i, 1, m)
		uwu = uwu * i % mod;
	
	cout << m << " " << (calc(a) + calc(b) - uwu + mod) % mod << "\n";
}


int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	#ifdef kaguya
		freopen(file".inp", "r", stdin); freopen(file".out", "w", stdout);
	#endif

	int q = 1;
//	cin >> q;
	while (q--)
		solve();

	return 0;
}
/*



*/


详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 7752kb

input:

3
1 2 3

output:

2 6

result:

ok 2 number(s): "2 6"

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 7808kb

input:

1
1

output:

1 1000000006

result:

wrong answer 2nd numbers differ - expected: '1', found: '1000000006'