QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#457549#8829. Aibohphobiaucup-team1525#Compile Error//C++201.3kb2024-06-29 13:15:542024-06-29 13:15:54

Judging History

你现在查看的是最新测评结果

  • [2024-06-29 13:15:54]
  • 评测
  • [2024-06-29 13:15:54]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int N=1000005;
int t;
char s[N];
int cnt[30],ord[30];
bool cmp(int x,int y)
{
    return cnt[x]>cnt[y];
}
int main()
{
    scanf("%d",&t);
    while (t--)
    {
        scanf("%s",s);
        int n=strlen(s);
        for (int i=0;i<=25;++i)
        {
            cnt[i]=0;
            ord[i]=i;
        }
        for (int i=0;i<n;++i)
            cnt[s[i]-'a']++;
        sort(ord,ord+26,cmp);
        if (cnt[ord[2]]==0)
        {
            if (n==1)
            {
                puts("YES");
                putchar('a'+ord[0]);
                putchar('\n');
                continue;
            }
            if (cnt[ord[1]]==1)
            {
                puts("YES");
                putchar('a'+ord[1]);
                for (int i=1;i<=cnt[ord[0]];++i)
                    putchar('a'+ord[0]);
                putchar('\n');
                continue;
            }
            puts("NO");
            continue;
        }
        puts("YES");
        while (cnt[ord[0]])
        {
            for (int i=0;i<26;++i)
                if (cnt[ord[i]])
                {
                    putchar('a'+ord[i]);
                    --cnt[ord[i]];
                }
        }
        putchar('\n');
    }
    return 0;
}v

Details

answer.code:60:2: error: ‘v’ does not name a type
   60 | }v
      |  ^
answer.code: In function ‘int main()’:
answer.code:13:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   13 |     scanf("%d",&t);
      |     ~~~~~^~~~~~~~~
answer.code:16:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   16 |         scanf("%s",s);
      |         ~~~~~^~~~~~~~