求大神 如何优化

评测结果
编译成功

测试数据 #0: Accepted, time = 0 ms, mem = 560 KiB, score = 10
测试数据 #1: Accepted, time = 0 ms, mem = 556 KiB, score = 10
测试数据 #2: Accepted, time = 15 ms, mem = 556 KiB, score = 10
测试数据 #3: Accepted, time = 0 ms, mem = 560 KiB, score = 10
测试数据 #4: Accepted, time = 593 ms, mem = 556 KiB, score = 10
测试数据 #5: TimeLimitExceeded, time = 1015 ms, mem = 548 KiB, score = 0
测试数据 #6: Accepted, time = 0 ms, mem = 560 KiB, score = 10
测试数据 #7: TimeLimitExceeded, time = 1015 ms, mem = 548 KiB, score = 0
TimeLimitExceeded, time = 2638 ms, mem = 560 KiB, score = 60
代码
#include<iostream>
#include<algorithm>
using namespace std;
int n,m,now,a[25];
int main()
{
cin>>n>>m;

for(int i=1;i<=n;i++) a[i]=i;

do
{
now++;

if(now==m)

{
for(int i=1;i<=n;i++) cout<<a[i]<<' ';
return 0;
}

}while(next_permutation(a+1,a+n+1));
return 0;
}

2 条评论

  • 1

信息

ID
1092
难度
5
分类
组合数学 点击显示
标签
(无)
递交数
4512
已通过
1398
通过率
31%
被复制
11
上传者