QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#296090#7886. Not Another Eulerian Number Problem1366397866TL 337ms3860kbC++141.2kb2024-01-02 08:48:042024-01-02 08:48:04

Judging History

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

  • [2024-01-02 08:48:04]
  • 评测
  • 测评结果:TL
  • 用时:337ms
  • 内存:3860kb
  • [2024-01-02 08:48:04]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"
#define PII pair<int,int>
const int N=1e5+10;
void solve()
{
	int r,n,m,n0;
	cin>>r>>n>>m>>n0;
	vector<int>ans;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=r;j++)
		{
			ans.push_back(i);
		}
	}
	sort(ans.begin(),ans.end());
	deque<int>aas;
	for(int i=1;i<=r*n0;i++)
	{
		int x;
		cin>>x;
		aas.push_back(x);
	}
	int sum=0;
	do
	{
		deque<int>abb(aas);
		int flag=0;
		for(int i=0;i<ans.size();i++)
		{
			if(abb.size()&&ans[i]==abb.front())abb.pop_front();
			unordered_map<int,int>book;
			for(int j=0;j<i;j++)
			{
				book[ans[j]]++;
			}
			for(auto p:book)
			{
				if(p.second!=r&&p.first>ans[i])
				{
					flag=1;
					break;
				}
			}
			if(flag==1)break;
		}
		if((int)abb.size())flag=1;
		if(flag==0)
		{
			int cnt=0;
			for(int i=0;i<ans.size()-1;i++)
			{
				if(ans[i]>ans[i+1])cnt++;
			}
			if(cnt==m)sum++;
		}
	}while(next_permutation(ans.begin(),ans.end()));
	cout<<sum<<endl;
} 
signed main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int T=1;
//	cin>>T;
	while(T--)solve();
	return 0;
}  

詳細信息

Test #1:

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

input:

1 4 2 2
2 1

output:

7

result:

ok 1 number(s): "7"

Test #2:

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

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: 3588kb

input:

1 1 0 1
1

output:

1

result:

ok 1 number(s): "1"

Test #4:

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

input:

3 1 0 1
1 1 1

output:

1

result:

ok 1 number(s): "1"

Test #5:

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

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: 3652kb

input:

5 1 0 1
1 1 1 1 1

output:

1

result:

ok 1 number(s): "1"

Test #7:

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

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: 3560kb

input:

1 3 2 1
1

output:

1

result:

ok 1 number(s): "1"

Test #9:

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

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: 1ms
memory: 3808kb

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: 1ms
memory: 3844kb

input:

3 3 2 1
1 1 1

output:

15

result:

ok 1 number(s): "15"

Test #12:

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

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: 0ms
memory: 3648kb

input:

1 4 0 4
4 2 1 3

output:

0

result:

ok 1 number(s): "0"

Test #14:

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

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: 1ms
memory: 3508kb

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: 0ms
memory: 3572kb

input:

2 4 2 1
1 1

output:

58

result:

ok 1 number(s): "58"

Test #17:

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

input:

2 4 1 2
1 1 2 2

output:

14

result:

ok 1 number(s): "14"

Test #18:

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

input:

1 8 7 3
2 1 3

output:

0

result:

ok 1 number(s): "0"

Test #19:

score: 0
Accepted
time: 27ms
memory: 3612kb

input:

1 8 0 4
1 2 3 4

output:

1

result:

ok 1 number(s): "1"

Test #20:

score: 0
Accepted
time: 32ms
memory: 3592kb

input:

1 8 4 4
4 3 1 2

output:

771

result:

ok 1 number(s): "771"

Test #21:

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

input:

1 8 1 4
4 3 2 1

output:

0

result:

ok 1 number(s): "0"

Test #22:

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

input:

1 8 7 1
1

output:

1

result:

ok 1 number(s): "1"

Test #23:

score: 0
Accepted
time: 337ms
memory: 3648kb

input:

1 9 2 5
4 3 1 5 2

output:

0

result:

ok 1 number(s): "0"

Test #24:

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

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: 337ms
memory: 3552kb

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: 333ms
memory: 3580kb

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: 337ms
memory: 3860kb

input:

1 9 3 3
1 2 3

output:

20420

result:

ok 1 number(s): "20420"

Test #28:

score: -100
Time Limit Exceeded

input:

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

output:


result: