QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#596497 | #9353. Interesting Permutation | yeah14 | WA | 219ms | 6048kb | C++17 | 2.3kb | 2024-09-28 15:54:25 | 2024-09-28 15:54:29 |
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&&maxx!=n-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: 3700kb
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: 219ms
memory: 6048kb
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 0 0 0 0 53607552 0 0 0 880981099 0 828256093 16 77901294 5930496 2 0 382607616 61638510 342553994 2 0 0 0 0 727807972 0 0 0 80 0 96768 0 0 0 0 0 2 0 291200 0 0 2 0 2 0 0 0 0 0 4 433369411 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10967040 2 0 0 0 0 2304 0 0 1397760 89856 0 2 32 0 0 0 0 0 0 2304 0 190080...
result:
wrong answer 7th lines differ - expected: '24576', found: '0'