QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#624779#9353. Interesting PermutationeleanorschCompile Error//C++20894b2024-10-09 16:36:372024-10-09 16:36:44

Judging History

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

  • [2024-10-09 16:36:44]
  • 评测
  • [2024-10-09 16:36:37]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int mod = 1e9 + 7;


ll qsm(ll a, ll b) {
	ll tem = 1 ;
	while (b) {
		if (b & 1)
			tem *= a ;
		a *= a;
		b >>= 1 ;
	}
	return tem ;
}

void Solve() {
	int n, flag = 0 ;
	ll ans = 1 ;
	cin >> n ;
	vector<int> a(n);
	for (int i = 0 ; i < n ; i++) {
		cin >> a[i];
		if (a[i] < i)
			flag = 1 ;
		if(a[i] && a[i] < a[i-1])flag = ;
	}
	if (flag || a[0] != 0 || a[n - 1] != n - 1) {
		cout << 0 << '\n';
		return ;
	}
	for (int i = 1 ; i < n ; ) {
		ll tem = 0 ;
		ans *= 2 ;
		ans %= mod ;
		i++;
		while (a[i] == a[i - 1]) {
			tem++ ;
			i++ ;
		}
		while (tem > 1) {
			ans *= tem ;
			ans %= mod ;
			tem--;
		}
	}
	cout << ans << '\n';
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);

	int T = 1 ;
	cin >> T ;

	while (T--)
		Solve();

	return 0 ;
}

详细

answer.code: In function ‘void Solve()’:
answer.code:27:49: error: expected primary-expression before ‘;’ token
   27 |                 if(a[i] && a[i] < a[i-1])flag = ;
      |                                                 ^