QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#596387 | #9353. Interesting Permutation | yeah14 | WA | 230ms | 4420kb | C++17 | 2.3kb | 2024-09-28 15:40:12 | 2024-09-28 15:40:12 |
Judging History
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 maxx1 = -2;
int fm = 0;
bool op = 0;//ans?0;
int cnt = 0;//重复
for (int i = 1; i <= n; i++) {
cin >> a[i];
if (a[i] < a[i - 1]||a[1] != 0||(a[i]==0&&i!=1))op = 1;
if (a[i] == a[i - 1]&&i!=1) {
cnt++;
}
else {
cnt = 0;
}
//if (cnt >= maxx - maxx1)op = 1;
if (maxx < a[i]) {
fm = i;
maxx1 = maxx;
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 *= max((n - a[i] - (i - 1)) * 2,1LL);
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: 100
Accepted
time: 0ms
memory: 3636kb
input:
3 3 0 2 2 3 0 1 2 3 0 2 3
output:
2 4 0
result:
ok 3 lines
Test #2:
score: -100
Wrong Answer
time: 230ms
memory: 4420kb
input:
10039 14 5 6 7 8 9 10 11 12 13 13 13 13 13 13 14 0 5 6 7 8 9 10 11 12 13 14 14 14 14 1 1 14 0 5 4 8 9 10 11 12 13 13 13 13 13 13 45 0 1 1 2 2 3 5 5 6 6 8 9 11 13 15 17 18 18 20 22 22 24 26 26 26 26 27 27 27 28 30 32 32 33 34 34 34 36 36 38 38 38 39 39 44 24 0 2 3 5 7 9 9 10 11 12 13 14 14 14 14 15 1...
output:
0 0 0 0 370967568 795973310 37158912 40642560 53607552 151508838 621095536 528716993 880981099 581898073 828256093 16 77901294 5930496 2 283331911 382607616 61638510 342553994 2 0 64766632 34816668 0 727807972 0 110207958 100859904 80 228058235 96768 0 747721894 96 542976358 983053759 2 134858616 29...
result:
wrong answer 5th lines differ - expected: '0', found: '370967568'