QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#273277#7886. Not Another Eulerian Number ProblemRainningLoveAC ✓810ms3856kbC++201.3kb2023-12-02 22:44:322023-12-02 22:44:32

Judging History

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

  • [2023-12-02 22:44:32]
  • 评测
  • 测评结果:AC
  • 用时:810ms
  • 内存:3856kb
  • [2023-12-02 22:44:32]
  • 提交

answer

#include<bits/stdc++.h>
#define ll long long
#define pii pair<int, int>

using namespace std;

int n,m,a,n0;
int B[20];
vector<int> p,b;
long long A[20];
long long qm(long long a,long long b) {
	long long ans=1;
	while(b) {
		if(b&1)ans=ans*a;
		a=a*a;
		b>>=1;
	}
	return ans;
}


int check() {
	vector<int> arr;
	queue<int> q;
	for(int i=1;i<=n0*a;i++) {
		q.push(B[i]);
	}

	int c=0;
	for(int i=0;i<p.size();i++) {
		arr.push_back(b[p[i]]);
		if(!q.empty() && q.front()==b[p[i]])q.pop();
	}
	for(int i=0;i+1<p.size();i++) {
		if(i+1<p.size() && arr[i]>arr[i+1])c++;
	}

	if(!q.empty() || c!=m)return 0;

	vector<int> cnt(11,0);
	set<int> st;
	for(int i=0;i<arr.size();i++) {
		cnt[arr[i]]++;
		st.insert(arr[i]);
		if(cnt[arr[i]]==a)st.erase(arr[i]);

		if(st.upper_bound(arr[i])!=st.end())return 0;
	}

	return 1;


	
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	
	cin>>a>>n>>m>>n0;
	for(int i=1;i<=a*n0;i++) {
		cin>>B[i];
	}
	A[0]=1;
	for(int i=1;i<=10;i++)A[i]=A[i-1]*i;
	for(int i=0;i<n*a;i++) {
		p.push_back(i);
	}

	for(int i=1;i<=n;i++) {
		for(int j=1;j<=a;j++) {
			b.push_back(i);
		}
	}

	long long ans=0;
	do {
		if(check())ans++;
	}while(next_permutation(p.begin(),p.end()));

	ans/=qm(A[a],n);
	cout<<ans;
	
	
	return 0;
}

这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3564kb

input:

1 4 2 2
2 1

output:

7

result:

ok 1 number(s): "7"

Test #2:

score: 0
Accepted
time: 6ms
memory: 3668kb

input:

2 4 2 2
1 2 2 1

output:

19

result:

ok 1 number(s): "19"

Test #3:

score: 0
Accepted
time: 0ms
memory: 3508kb

input:

1 1 0 1
1

output:

1

result:

ok 1 number(s): "1"

Test #4:

score: 0
Accepted
time: 0ms
memory: 3780kb

input:

3 1 0 1
1 1 1

output:

1

result:

ok 1 number(s): "1"

Test #5:

score: 0
Accepted
time: 0ms
memory: 3568kb

input:

4 1 0 1
1 1 1 1

output:

1

result:

ok 1 number(s): "1"

Test #6:

score: 0
Accepted
time: 0ms
memory: 3560kb

input:

5 1 0 1
1 1 1 1 1

output:

1

result:

ok 1 number(s): "1"

Test #7:

score: 0
Accepted
time: 810ms
memory: 3632kb

input:

10 1 0 1
1 1 1 1 1 1 1 1 1 1

output:

1

result:

ok 1 number(s): "1"

Test #8:

score: 0
Accepted
time: 0ms
memory: 3512kb

input:

1 3 2 1
1

output:

1

result:

ok 1 number(s): "1"

Test #9:

score: 0
Accepted
time: 57ms
memory: 3560kb

input:

3 3 2 3
2 2 2 3 3 3 1 1 1

output:

0

result:

ok 1 number(s): "0"

Test #10:

score: 0
Accepted
time: 57ms
memory: 3624kb

input:

3 3 2 2
1 1 2 2 2 1

output:

5

result:

ok 1 number(s): "5"

Test #11:

score: 0
Accepted
time: 61ms
memory: 3564kb

input:

3 3 2 1
1 1 1

output:

15

result:

ok 1 number(s): "15"

Test #12:

score: 0
Accepted
time: 56ms
memory: 3508kb

input:

3 3 1 2
2 2 2 1 1 1

output:

2

result:

ok 1 number(s): "2"

Test #13:

score: 0
Accepted
time: 1ms
memory: 3852kb

input:

1 4 0 4
4 2 1 3

output:

0

result:

ok 1 number(s): "0"

Test #14:

score: 0
Accepted
time: 6ms
memory: 3556kb

input:

2 4 1 4
1 4 4 3 3 2 2 1

output:

0

result:

ok 1 number(s): "0"

Test #15:

score: 0
Accepted
time: 7ms
memory: 3668kb

input:

2 4 2 4
1 3 3 2 2 4 4 1

output:

1

result:

ok 1 number(s): "1"

Test #16:

score: 0
Accepted
time: 6ms
memory: 3560kb

input:

2 4 2 1
1 1

output:

58

result:

ok 1 number(s): "58"

Test #17:

score: 0
Accepted
time: 3ms
memory: 3624kb

input:

2 4 1 2
1 1 2 2

output:

14

result:

ok 1 number(s): "14"

Test #18:

score: 0
Accepted
time: 5ms
memory: 3624kb

input:

1 8 7 3
2 1 3

output:

0

result:

ok 1 number(s): "0"

Test #19:

score: 0
Accepted
time: 5ms
memory: 3624kb

input:

1 8 0 4
1 2 3 4

output:

1

result:

ok 1 number(s): "1"

Test #20:

score: 0
Accepted
time: 3ms
memory: 3632kb

input:

1 8 4 4
4 3 1 2

output:

771

result:

ok 1 number(s): "771"

Test #21:

score: 0
Accepted
time: 6ms
memory: 3664kb

input:

1 8 1 4
4 3 2 1

output:

0

result:

ok 1 number(s): "0"

Test #22:

score: 0
Accepted
time: 5ms
memory: 3828kb

input:

1 8 7 1
1

output:

1

result:

ok 1 number(s): "1"

Test #23:

score: 0
Accepted
time: 55ms
memory: 3600kb

input:

1 9 2 5
4 3 1 5 2

output:

0

result:

ok 1 number(s): "0"

Test #24:

score: 0
Accepted
time: 57ms
memory: 3564kb

input:

1 9 7 8
6 5 8 3 4 7 2 1

output:

0

result:

ok 1 number(s): "0"

Test #25:

score: 0
Accepted
time: 56ms
memory: 3848kb

input:

1 9 7 7
5 3 2 4 7 6 1

output:

0

result:

ok 1 number(s): "0"

Test #26:

score: 0
Accepted
time: 54ms
memory: 3844kb

input:

1 9 7 6
2 1 3 5 6 4

output:

0

result:

ok 1 number(s): "0"

Test #27:

score: 0
Accepted
time: 58ms
memory: 3560kb

input:

1 9 3 3
1 2 3

output:

20420

result:

ok 1 number(s): "20420"

Test #28:

score: 0
Accepted
time: 574ms
memory: 3504kb

input:

1 10 0 10
5 6 10 1 3 2 4 7 8 9

output:

0

result:

ok 1 number(s): "0"

Test #29:

score: 0
Accepted
time: 527ms
memory: 3780kb

input:

1 10 7 2
2 1

output:

30973

result:

ok 1 number(s): "30973"

Test #30:

score: 0
Accepted
time: 566ms
memory: 3856kb

input:

1 10 1 6
6 3 5 2 4 1

output:

0

result:

ok 1 number(s): "0"

Test #31:

score: 0
Accepted
time: 517ms
memory: 3824kb

input:

1 10 2 1
1

output:

47840

result:

ok 1 number(s): "47840"

Test #32:

score: 0
Accepted
time: 687ms
memory: 3604kb

input:

1 10 5 2
2 1

output:

689155

result:

ok 1 number(s): "689155"

Extra Test:

score: 0
Extra Test Passed