提交记录 3756


用户 题目 状态 得分 用时 内存 语言 代码长度
attack noi18a. 【NOI2018】归程 Time Limit Exceeded 0 4 s 12 KB C++ 1.13 KB
提交时间 评测时间
2018-07-18 17:19:28 2020-07-31 21:31:32
#include<cstdio>
#include<map>
#include<cstring>
#include<queue>
#include<algorithm>
#define rg register 
using namespace std;
const int MAXN = 11, INF = 1e9 + 10, mod = 998244353;
inline int read() {
	char c = getchar(); int x = 0, f = 1;
	while(c < '0' || c > '9') {if(c == '-') f = -1; c = getchar();}
	while(c >= '0' && c <= '9')x = x * 10 + c - '0', c = getchar();
	return x * f;
}
int QwQ, N, a[MAXN], ed[MAXN];
int pd(int *a, int *b) {
	for(rg int i = 1; i <= N; i++)
		if(a[i] != b[i]) return 0;
	return 1;
}
bool calc() {
	rg int times = 0, num = 0;
	for(rg int i = 1; i <= N; i++) num += abs(i - a[i]);
	for(rg int i = 1; i <= N; i++) 
		for(rg int j = i - 1; j >= 1; j--)
			if(a[i] < a[j]) times++;
	return (times * 2) == num;
}
int main() {
	QwQ = read();
	while(QwQ--) {
		N = read();
		for(rg int i = 1; i <= N; i++) a[i] = read(), ed[i] = N - i + 1;
		int ans = 0;
		next_permutation(a + 1, a + N + 1);
		while(!pd(a, ed)) 
			ans += calc(), next_permutation(a + 1, a + N + 1);
		printf("%d\n", ans);
	}
	return 0;
}
/*
5
10
1 2 3 4 5 6 7 8 9 10
10
1 2 3 4 5 6 7 8 9 10
10
1 2 3 4 5 6 7 8 9 10
10
1 2 3 4 5 6 7 8 9 10
10
1 2 3 4 5 6 7 8 9 10
*/

CompilationN/AN/ACompile OKScore: N/A

Testcase #14 s8 KBTime Limit ExceededScore: 0

Testcase #24 s8 KBTime Limit ExceededScore: 0

Testcase #34 s8 KBTime Limit ExceededScore: 0

Testcase #44 s8 KBTime Limit ExceededScore: 0

Testcase #54 s8 KBTime Limit ExceededScore: 0

Testcase #618.22 us12 KBRuntime ErrorScore: 0

Testcase #720.33 us8 KBRuntime ErrorScore: 0

Testcase #84 s8 KBTime Limit ExceededScore: 0

Testcase #921.28 us8 KBRuntime ErrorScore: 0

Testcase #1021.15 us8 KBRuntime ErrorScore: 0

Testcase #1120.86 us8 KBRuntime ErrorScore: 0

Testcase #1221.49 us8 KBRuntime ErrorScore: 0

Testcase #1320.7 us8 KBRuntime ErrorScore: 0

Testcase #1420.85 us8 KBRuntime ErrorScore: 0

Testcase #154 s8 KBTime Limit ExceededScore: 0

Testcase #164 s8 KBTime Limit ExceededScore: 0

Testcase #1721.35 us8 KBRuntime ErrorScore: 0

Testcase #1821.14 us8 KBRuntime ErrorScore: 0

Testcase #1921.76 us8 KBRuntime ErrorScore: 0

Testcase #2021.16 us8 KBRuntime ErrorScore: 0


Judge Duck Online | 评测鸭在线
Server Time: 2026-04-18 01:10:56 | Loaded in 2 ms | Server Status
个人娱乐项目,仅供学习交流使用 | 捐赠