henrytb 的博客

henrytb 的博客

NOIP2018PJ凉凉记

posted on 2018-11-20 21:49:14 | under 游记 |

复赛以前期中考试凉凉...同时名字颜色也掉蓝了...

这预兆着NOIP同样也...

凉凉!

其实凉了还是有一些原因的...我太...颓废了。

考场经历

T1...1分钟敲完...

核心代码:

string a;
while(cin>>a)ans+=a.size();

100分get...

然而T2...

咕咕CCF官方才64...仔细查看,改了一行后...

竟然AC了!!!

原来考场上打的:

#include <cstdio>
#include <cstdlib>
#include <iostream>
using namespace std;
int n,m,c[100005],p,s1,s2,ans;
long long ql=0,qh=0,cha=0,now=1e18;
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d",&c[i]);
    scanf("%d%d%d%d",&m,&p,&s1,&s2);
    for(int i=1;i<m;i++)ql+=(long long)(m-i)*(long long)c[i];
    for(int i=m+1;i<=n;i++)qh+=(long long)(i-m)*(long long)c[i];
    if(p<m)ql+=(long long)(m-p)*(long long)s1;
    else if(p>m)qh+=(long long)(p-m)*(long long)s1;
    cha=ql-qh;
    for(int i=1;i<m;i++){
        cha+=(long long)(m-i)*(long long)s2;
        if(abs(cha)<now)ans=i,now=abs(cha);
        cha-=(long long)(m-i)*(long long)s2;
    }
    now=min(now,abs(cha));
    for(int i=m+1;i<=n;i++){
        cha-=(long long)(i-m)*(long long)s2;
        if(abs(cha)<now)ans=i,now=abs(cha);
        cha+=(long long)(i-m)*(long long)s2;
    }
    printf("%d\n",ans);
    return 0;
}

改了一行的:

#include <cstdio>
#include <cstdlib>
#include <iostream>
using namespace std;
int n,m,c[100005],p,s1,s2,ans;
long long ql=0,qh=0,cha=0,now=1e18;
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d",&c[i]);
    scanf("%d%d%d%d",&m,&p,&s1,&s2);
    for(int i=1;i<m;i++)ql+=(long long)(m-i)*(long long)c[i];
    for(int i=m+1;i<=n;i++)qh+=(long long)(i-m)*(long long)c[i];
    if(p<m)ql+=(long long)(m-p)*(long long)s1;
    else if(p>m)qh+=(long long)(p-m)*(long long)s1;
    cha=ql-qh;
    for(int i=1;i<m;i++){
        cha+=(long long)(m-i)*(long long)s2;
        if(abs(cha)<now)ans=i,now=abs(cha);
        cha-=(long long)(m-i)*(long long)s2;
    }
    if(abs(cha)<now)ans=m,now=abs(cha);   //这一行改了
    for(int i=m+1;i<=n;i++){
        cha-=(long long)(i-m)*(long long)s2;
        if(abs(cha)<now)ans=i,now=abs(cha);
        cha+=(long long)(i-m)*(long long)s2;
    }
    printf("%d\n",ans);
    return 0;
}

原因:粗心大意...

粗心大意毁了我一生打过的所有比赛...

T3dp没想出来,就用贪心去骗分...

结果...

一分(除了输出0的10分)都没骗到!!!

凉凉...

T4不会,果断输出1

才骗了4分...

后来知道这题只是一个dfs...

凉...

反思

T2错得最不应该!