不知道有没有人遇到和我一样的问题

近日突然想起来洛谷部分题目存在判断失误问题(包括之前遇到过的一些题已经忘记题号),以下面两道题为例,贴出我的得分情况、输出情况和代码(已确认无空格和换行等差异)

P1067

1

我的代码

#include<stdio.h>
int main(){
    int n,t;
    scanf("%d",&n);
    t=n;
    while(n--){
        int a;
        scanf("%d",&a);
        if(n!=0){
            if(a>0&&(a!=1&&a!=-1)){
                if(t==n+1)
                    printf("%dx^%d",a,n+1);
                else
                    printf("+%dx^%d",a,n+1);
            }else if(a==-1||a==1){
                if(a>0&&t==n+1)
                    printf("x^%d",n+1);
                else if(a>0&&t!=n+1)
                    printf("+x^%d",n+1);
                else
                    printf("-x^%d",n+1);
            }else if(a<0&&(a!=1&&a!=-1)){
                printf("%dx^%d",a,n+1);
            }else{
                t--;
            }
        }
        else{
            if(a>0&&(a!=1&&a!=-1)){
                if(t==n+1)
                    printf("%dx",a);
                else
                    printf("+%dx",a);
            }else if(a==-1||a==1){
                if(a>0&&t==n+1)
                    printf("x");
                else if(a>0&&t!=n+1)
                    printf("+x");
                else
                    printf("-x");
            }else if(a<0&&(a!=1&&a!=-1)){
                printf("%dx",a);
            }else{
                t--;
            }
        }
    }
    int a;
    scanf("%d",&a);
    if(a>0&&t!=0)
        printf("+");
    printf("%d\n",a);
}

AC代码

#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,a,i;
    cin>>n;
    for(i=n;i>=0;i--)
    {
        cin>>a;
        if(a)
        {
            if(i!=n&&a>0) cout<<"+";
            if(abs(a)>1||i==0) cout<<a;
            if(a==-1&&i) cout<<"-";
            if(i>1) cout<<"x^"<<i;
            if(i==1) cout<<"x";
        }
    }
    return 0;
}

P1098

这道题只下载了第7个测试点

输入
2 8 2
--09-8-w-er-7h-08w-e7-hc-r890-q7w-eh-rc98-07-q8-ewr-8h-c-8-294-5-dsf--k-h-2-48-3k-h-sd-fq-a-
输出
我的答案:--09-8-w-er-7h-08w-e7-hcQQQQQQQQPPPPPPPPOOOOOOOONNNNNNNNMMMMMMMMLLLLLLLLKKKKKKKKJJJJJJJJIIIIIIIIHHHHHHHHGGGGGGGGFFFFFFFFEEEEEEEEDDDDDDDDr890-q7w-ehQQQQQQQQPPPPPPPPOOOOOOOONNNNNNNNMMMMMMMMLLLLLLLLKKKKKKKKJJJJJJJJIIIIIIIIrc98-07-q8-ewr-8h-c-8-2945-dsf--k-h-23333333348-3k-hRRRRRRRRQQQQQQQQPPPPPPPPOOOOOOOONNNNNNNNMMMMMMMMLLLLLLLLKKKKKKKKJJJJJJJJIIIIIIIIsdEEEEEEEEfq-a-
AC代码的答案:--09-8-w-er-7h-08w-e7-hcQQQQQQQQPPPPPPPPOOOOOOOONNNNNNNNMMMMMMMMLLLLLLLLKKKKKKKKJJJJJJJJIIIIIIIIHHHHHHHHGGGGGGGGFFFFFFFFEEEEEEEEDDDDDDDDr890-q7w-ehQQQQQQQQPPPPPPPPOOOOOOOONNNNNNNNMMMMMMMMLLLLLLLLKKKKKKKKJJJJJJJJIIIIIIIIrc98-07-q8-ewr-8h-c-8-2945-dsf--k-h-23333333348-3k-hRRRRRRRRQQQQQQQQPPPPPPPPOOOOOOOONNNNNNNNMMMMMMMMLLLLLLLLKKKKKKKKJJJJJJJJIIIIIIIIsdEEEEEEEEfq-a-

我的代码

#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
int main(){
    int p1,p2,p3;
    scanf("%d %d %d",&p1,&p2,&p3);
    string n;
    cin>>n;
    for(int i=0;n[i];i++)
    {

        if(n[i]=='-'&&(-n[i-1]+n[i+1]<=25&&-n[i-1]+n[i+1]>0)){
            if(p1==1){
                int cha=n[i+1]-n[i-1]-1;
                int start=n[i-1]+1-'a';
                if(n[i-1]<='Z'&&n[i-1]>='A') start=n[i-1]+1-'A';
                if(p3==1){
                    for(int pr='a'+start;pr-'a'-start<cha;pr++)
                        for(int pr2=0;pr2<p2;pr2++)
                            printf("%c",pr);
                }else{
                    for(int pr='a'+start+cha-1;pr-'a'-start>=0;pr--)
                        for(int pr2=0;pr2<p2;pr2++)
                            printf("%c",pr);
                }
            }else if(p1==2){
                int cha=n[i+1]-n[i-1]-1;
                int start=n[i-1]+1-'A';
                if(n[i-1]<='z'&&n[i-1]>='a') start=n[i-1]+1-'a';
                if(p3==1){
                    for(int pr='A'+start;pr-'A'-start<cha;pr++)
                        for(int pr2=0;pr2<p2;pr2++)
                            printf("%c",pr);
                }else{
                    for(int pr='A'+start+cha-1;pr-'A'-start>=0;pr--)
                        for(int pr2=0;pr2<p2;pr2++)
                            printf("%c",pr);
                }
            }else{
                for(int pr=n[i-1]+1;pr<n[i+1];pr++) printf("*");
            }
        }else{
            printf("%c",n[i]);
        }
    }

}

AC代码

#include<bits/stdc++.h>
using namespace std;
int p1,p2,p3,i=0,k;
char ch[300],be,af,f,j,p;//p用于输出;
int main() {
    scanf("%d%d%d%s",&p1,&p2,&p3,ch);//输入;
    while(ch[i]){//当ch[i]有值时;
        be=ch[i-1];af=ch[i+1];f=ch[i];//f存储ch[i],便于判断;
        if(f=='-'&&af>be&&(be>='0'&&af<='9'||be>='a'&&af<='z')){//意思是ch[i]若为'-',就判断其前后是否满足条件,满足进入循环;
            for(p3==1?j=be+1:j=af-1; p3==1?j<af:j>be; p3==1?j++:j--){
                p=j;//j是整形变量,p是字符型变量,这样是将p赋值为ASCII码为j的字符;
                if(p1==2)//是否大写;
                    p=(p>='a')?p-32:p;//如果是字母就转成大写
                else if(p1==3) p='*';//是否输出'*'
                for(k=0; k<p2; k++)//输出p2个
                    printf("%c",p);
            }
        }
        else
            printf("%c",f);//如果ch[i]是非'-'或者其前后不满足条件,就原样输出;
        i++;//一定要放在后面,不然会出错QAQ;
    }
    return 0;
}