首页 > 其他 > 详细

2020-10-24 JZ集训总结

时间:2020-10-24 22:53:22      阅读:21      评论:0      收藏:0      [点我收藏+]

原网址请点击这里

做的是C组的模拟题,题目难度中等。但是只拿了15分(还是水的数据)。有两道本可以AC的。

T2的精度,好像是因为abs过后会产生精度问题,然后就挂了。这个没什么好说的,解决方法就是+0.00001就过去了。

T3dp就好了,用f[i] = f[work[j].s] - 1 + work[j].c;f[i]是第i天的最大价值。因为调试结束过后输出的换行符没有删掉。考完过后改掉一交就AC了(md心态崩了)。

T4和T1的话,比赛时是没有打出来的。

T1具体来说就是全排列(next_permutation,是将一个数组按字典序全排列的函数,字典序由小到大,且从当前状态开始)。如下为AC代码

#include <iostream>
#include <cstdio>
#include <cstring>
#include <queue>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <stack>

using namespace std;
int num[6] = {0, 1, 2, 3, 4, 5};
string str[8];
string ans;
vector <string> v;
int main()
{
	for(int i = 0; i < 6; i++) cin >> str[i];
	do
	{
		ans = str[num[0]] + str[num[1]] + str[num[2]];
		if(ans[0] != str[num[3]][0] || ans[3] != str[num[3]][1] || ans[6] != str[num[3]][2])
			continue;
		if(ans[1] != str[num[4]][0] || ans[4] != str[num[4]][1] || ans[7] != str[num[4]][2])
			continue;
		if(ans[2] != str[num[5]][0] || ans[5] != str[num[5]][1] || ans[8] != str[num[5]][2])
			continue;
		v.push_back(ans);
    }while(next_permutation(num,num+6));
    if(v.size() ==0)
    {
        printf("0\n");
    }
    else
    {
        sort(v.begin(),v.end());
        for(int i=0;i<9;i++)
        {
            printf("%c",v[0][i]);
            if((i+1) %3 ==0) printf("\n");
        }
    }

    return 0;

}

如果在v.push_back(ans)的下一行break会错掉两个点,不知道是什么原因。

2020-10-24 JZ集训总结

原文:https://www.cnblogs.com/ttt1493b/p/13869969.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!