WA100求助!

P1464 Function

Diamond_ZuanShi @ 2024-08-05 10:41:15

错误详情

代码

#include<bits/stdc++.h>
using namespace std;
int n,a[10][10010],mx,r,x,p[10],tmp,ans,j;
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>r>>x;
        a[r][++p[r]]=x;
        mx=max(mx,x);
    }
    for(int i=1;i<=6;i++)
        sort(a[i]+1,a[i]+p[i]+1);
    for(int i=1;i<=6;i++)
    {
        j=1;
        while(j<=p[i])
        {
            ans++;
            tmp=j;
            j++;
            while(a[i][j]-a[i][tmp]<60&&j<=p[i])j++;
        }
    }
    cout<<ans<<endl;
    return 0;
}

话说为什么我100了还会WA?


by goIdie @ 2024-08-05 10:44:26

@Diamond_ZuanShi ,把能开long long的都开开,或直接#define int long long就过了,求关


by Diamond_ZuanShi @ 2024-08-05 10:45:36

OK,已关。 PS:@goIdie 能互关吗?


by goIdie @ 2024-08-05 10:47:15

@Diamond_ZuanShi ,目前不太支持


by Diamond_ZuanShi @ 2024-08-05 10:47:57

不对,我代码好像发错了,我再发一遍,sorry

#include<bits/stdc++.h>
using namespace std;
long long x,y,z,ans[155][155][155];
long long w(int a,int b,int c)
{
    if(a<=0||b<=0||c<=0)return 1;
    if(a>20||b>20||c>20)return w(20,20,20);
    if(ans[a][b][c])return ans[a][b][c];
    if(a<b&&b<c)ans[a][b][c]=w(a,b,c-1)+w(a,b-1,c-1)-w(a,b-1,c);
    else ans[a][b][c]=w(a-1,b,c)+w(a-1,b-1,c)+w(a-1,b,c-1)-w(a-1,b-1,c-1);
    return ans[a][b][c];
}
int main()
{   
    while(cin>>x>>y>>z)
    {
        if(x==-1&&y==-1&&z==-1)break;
        cout<<"w("<<x<<", "<<y<<", "<<z<<") = "<<w(x,y,z)<<endl;
    }
    return 0;
}

by ouxiyao @ 2024-08-05 14:47:24

@goIdie long long main()?


by goIdie @ 2024-08-05 18:16:59

@ouxiyao ,可以改成signed main


by Diamond_ZuanShi @ 2024-08-05 20:30:38

对不起,我发现我帖子里的错误代码好像贴错了,真正的错误代码在第四个帖,辛苦各位大佬再帮我看看。


by ouxiyao @ 2024-08-06 13:41:02

x,y,z为long long ,读进函数变成int了? 还有,题目说了,x,y,z有一个大于20就全部变为20,防止爆数据,特判在主程序


|