社区讨论

想对洛谷有题的评测提个小建议

题目总版参与者 11已保存回复 19

讨论操作

快速查看讨论及其快照的属性,并进行相关操作。

当前回复
19 条
当前快照
1 份
快照标识符
@mi6ye5us
此快照首次捕获于
2025/11/20 12:50
4 个月前
此快照最后确认于
2025/11/20 15:31
4 个月前
查看原帖
在看过一些DALAO\mathcal{DALAO}提的SPJ\mathrm{SPJ}的意见后,蒟蒻我好像弄出了一种SPJ\mathrm{SPJ}评测方法
就像DALAO\mathcal{DALAO}们说的那样,把std\mathrm{std}的填空部分抠掉,换成下划线++空格之类的、统一的形式,然后在抠掉的std\mathrm{std}前面,用#define ___x___ string的形式搞上选手填写的答案(string\mathrm{string}部分);最后在一些地方加上调试信息(蒟蒻搞不出来了QAQ\mathfrak{QAQ}),编译一下,跑一遍评测数据就OK\mathrm{OK}啦~
以下附上我的概念代码
CPP
#include<cstdio>
#ifndef LUOGU_YOUTI 
#define LUOGU_YOUTI
#define STU_ANS_MAX_SIZE 500020
FILE *ifstuans,*ifstd,*ofstd;
#endif
class stu_ans{
	private:
		char ans[STU_ANS_MAX_SIZE];
		int size,bufpos;
	public:
		stu_ans()
		{
			
		}
		~stu_ans()
		{
			
		}
		stu_ans(FILE* fin)
		{
			ans[size=fread(ans,sizeof(char),STU_ANS_MAX_SIZE,fin)] = '\0';
			bufpos = 0;
		}
		void init(FILE* fin)
		{
			ans[size=fread(ans,sizeof(char),STU_ANS_MAX_SIZE,fin)] = '\0';
			bufpos = 0;
		}
		void ans_print(FILE *fout)
		{
			int i=0,j=1;
			
			for(;ans[i];++j)
			{
				fprintf(fout,"#define ____%d____ ",j);
				for(;ans[i];++i)
				{
					fprintf(fout,"%c",ans[i]);
					if(ans[i]=='\n')
					{
						++i;
						break;
					}
				}
			}
		}
		void std_print(FILE *fout)
		{
			fwrite(ans,sizeof(char),size,fout);
		}
};
stu_ans stu,src;
int main()
{
	ifstuans=fopen("stu_ans.in","r");
	ifstd=fopen("src.cpp","r");
	ofstd=fopen("std.cpp","a");
	stu.init(ifstuans);
	src.init(ifstd);
	stu.ans_print(ofstd);
	src.std_print(ofstd);
	return 0; 
}

NOIP2017TG初赛 T27\mathrm{NOIP2017TG\text{初赛}\space T27}为例,读入的答案为
CPP
i<=j
next[rank[i]]=rank[i+1]
higher=height[next[i]]-height[i]
shorter<higher
previous[next[i]]=previous[i]
// 最后一行有换行~
原题程序省略,跑一遍生成程序,效果如下:
CPP
#define ____1____ i<=j
#define ____2____ next[rank[i]]=rank[i+1]
#define ____3____ higher=height[next[i]]-height[i]
#define ____4____ shorter<higher
#define ____5____ previous[next[i]]=previous[i]
#include <iostream>
using namespace std;
#define MAXN 200000
#define infinity 2147483647
int answer[MAXN], height[MAXN], previous[MAXN], next[MAXN];
int rank[MAXN];
int n;
void sort(int l, int r)
{
    int x = height[rank[(l + r) / 2]], i = l, j = r, temp;
    while (i <= j)
    {
        while (height[rank[i]] < x)
            i++;
        while (height[rank[j]] > x)
            j--;
        if ((____1____))
        {
            temp = rank[i];
            rank[i] = rank[j];
            rank[j] = temp;
            i++;
            j--;
        }
    }
    if (i < r)
        sort(i, r);
    if (l < j)
        sort(l, j);
}
int main()
{
    cin >> n;
    int i, higher, shorter;
    for (i = 1; i <= n; i++)
    {
        cin >> height[i];
        rank[i] = i;
	}
	sort(1, n);
	for (i = 1; i <= n; i++)
	{
		previous[rank[i]] = rank[i - 1];
		(____2____);
	}
	for (i = n; i >= 2; i--)
	{
		higher = shorter = infinity;
		if (previous[i] != 0)
			shorter = height[i] - height[previous[i]];
		if (next[i] != 0)
			(____3____);
		if ((____4____))
			answer[i] = previous[i];
		else
			answer[i] = next[i];
		next[previous[i]] = next[i];
		(____5____);
	}
	for (i = 2; i <= n; i++)
		cout << i << ":" << answer[i];
	return 0;
}
//OK
希望管理员大大们能让洛谷有题变得更完善、更便捷!
蒟蒻的一点点想法。。。
2018-10-12 21:48:49

回复

19 条回复,欢迎继续交流。

正在加载回复...