QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#596206#9353. Interesting Permutationyeah14WA 0ms3696kbC++172.1kb2024-09-28 15:20:072024-09-28 15:20:13

Judging History

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

  • [2024-09-28 15:20:13]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3696kb
  • [2024-09-28 15:20:07]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ull long long
#define PII  pair<int ,int>
const int INF = -1145141919810;
const int mod = 1e9 + 7;
const int N = 1e7;
int a[N];
string s[6];
int vis[6][6];
int viss[6];
bool visss[6];
string t = "harbin";
bool op = 0;
int st[7], top = 0;
//harbin;0 h;1,a;2 r;3 b;4 i;5 n
void dfs(int x) {
	if (x >= 5&&op==0&&top==6) {
		/*for (int i = top - 1; i >= 0; i--) {
			cout << st[i] << " ";
		}
		cout << endl;*/
		op = 1;
	}
	if (op == 1)return;
	for (int i = 0; i < 6; i++) {
		if (viss[i])continue;
		if (vis[x][i]) {
			viss[i] = 1;
			for (int j = 0; j < 6; j++) {
				if (visss[j])continue;
				st[top++] = j;
				visss[j] = 1;
				dfs(j);
				if (op == 1)return;
				visss[j] = 0;
				top--;
			}
			viss[i] = 0;
		}
	}
}
void solve() {
	int n;
	cin >> n;
	int maxx = 0;
	int fm = 0;
	bool op = 0;//ans?0;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		if (a[i] < a[i - 1]||op==0)op = 1;
		if (maxx < a[i]) {
			fm = i;
			maxx = a[i];
		}
	}
	if (maxx != n - 1)op = 1;
	if (op == 1) {
		cout << 0 << endl;
		return;
	}
	int ans = 2;
	int t = 0;
	int tt = 1;
	for (int i = 2; i < fm; i++) {
		if (a[i] != a[i - 1]) {
			ans *= tt;
			ans %= mod;
			ans *= (n - a[i] - (i - 1)) * 2;
			ans %= mod;
			t = 0;
			tt = 1;
		}		
		if (a[i] == a[i - 1]) {
			t++;
			tt*= t;
			tt %= mod;
		}
	}
	if (tt != 1)ans *= tt;
	ans %= mod;
	t = 1;
	for (int i = fm+1; i <= n; i++) {
		ans *= t;
		ans %= mod;
		t++;
	}
	cout << ans << endl;
}
//&&(((sum[n]+k)%mid==0)||(sum[n]/mid!=(sum[n]+k)/mid)||(mid-(sum[n]%mid)>=k))
signed main() {
	int t=1;
	cin >> t;
	//t = 1;
	//er(9e6);
	while (t--)solve();
	
}
//int n;
//cin >> n;
//for (int i = 1; i <= n; i++) {
//	cin >> a[i];
//}
//int maxx = 0, minn = INF;
//int sum = 0;
//for (int i = n; i <= 1; i++) {
//	sum += minn;
//	if (top == 0) {
//		minn = a[i];
//		st[top++] = a[i];
//	}
//	else {
//		if (a[i] > top && a[i] > minn)
//	}
//}
//cout << maxx - minn << endl;
//7 2 1 4 5 1 3 3
//4 1000 1000 1000 1000
//0

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3696kb

input:

3
3
0 2 2
3
0 1 2
3
0 2 3

output:

0
0
0

result:

wrong answer 1st lines differ - expected: '2', found: '0'