lemon/cena C++ SPJ姿势

终于看懂了百度百科,(⊙o⊙)…
存一份代码

#include <bits/stdc++.h>   //cena
#define LL long long
using namespace std;
FILE *f_score,*f_stdout,*f_stdin,*f_out,*f_wrong;
int main(int argc,char*argv[])
{
    f_score=fopen("score.log","w");//打开得分文件
    f_stdout=fopen(argv[2],"r");//打开测试点标准输出文件
    int score=atoi(argv[1]);//取得测试点的分数
    f_stdin=fopen("math.in","r");//原始数据
    f_out=fopen("math.out","r");//用户输出
    f_wrong=fopen("report.log","w");//打开报告文件
    int a,b;
    fscanf(f_stdin,"%d%d",&a,&b);
    int ans;
    fscanf(f_out,"%d",&ans);
    if(abs(a+b-ans)<=2)
        f_printf(f_sorce,"10");
    else
        f_printf(f_sorce,"0");
    return 0;
}
#include<iostream>   //lemon
#include<cstdio>
#include<cstring>
#define LL long long
using namespace std;
struct P{int x,y;}p[1005];
LL dis[1005][1005];
LL f(int x)
{return (LL)x*(LL)x;}
bool use[1005];
int main(int argc,char **argv)
{
    FILE *f_stdin=fopen(argv[1],"r");//标准输入
    FILE *f_out=fopen(argv[2],"r");//选手输出
    FILE *f_stdout=fopen(argv[3],"r");//标准输出
    FILE *f_score=fopen(argv[5],"w");//分数输出
        FILE *f_wrong=fopen(argv[6],"w");//错误信息
    int n,k;
    fscanf(f_stdin,"%d%d",&n,&k);
    for(int i=1;i<=n;i++)
        fscanf(f_stdin,"%d%d",&p[i].x,&p[i].y);
    for(int i=1;i<n;i++)
    for(int j=i+1;j<=n;j++)
        dis[i][j]=f(p[i].x-p[j].x)+f(p[i].y-p[j].y);
    int x;
    for(int i=1;i<=k;i++)
    {
        fscanf(f_stdout,"%d",&x);
        use[x]=1;
    }
    LL Max=0;
    for(int i=1;i<n;i++)
    for(int j=i+1;j<=n;j++)
        if(dis[i][j]>Max&&!use[i]&&!use[j])
            Max=dis[i][j];
    int tot=0;
    memset(use,0,sizeof(use));
    bool b=0;
    while(fscanf(f_out,"%d",&x)!=EOF)
    {
        tot++;
        if(x<=0||x>n) 
        {b=1;break;}
        use[x]++;
    }
    if(tot!=k)
    {
        fprintf(f_score,"0");
        if(b)     fprintf(f_wrong,"输出错误");
        else{ 
        if(tot<k) fprintf(f_wrong,"输出过短");
        if(tot>k) fprintf(f_wrong,"输出过长");
        }
        return 0; 
    }
    LL Ans=0;
    for(int i=1;i<n;i++)
    for(int j=i+1;j<=n;j++)
        if(dis[i][j]>Ans&&!use[i]&&!use[j])
            Ans=dis[i][j];
    if(Ans==Max&&tot==k)
        fprintf(f_score,"10");
    else
    {
        fprintf(f_score,"0");
        if(tot==k&&Ans!=Max)
            fprintf(f_wrong,"答案错误");
    } 
}
  • 9
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值