QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#627045#7882. Linguistics Puzzlefrankly6WA 5ms3788kbC++172.1kb2024-10-10 14:34:532024-10-10 14:34:59

Judging History

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

  • [2024-10-10 14:34:59]
  • 评测
  • 测评结果:WA
  • 用时:5ms
  • 内存:3788kb
  • [2024-10-10 14:34:53]
  • 提交

answer

#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
const int MX=52;

int T, N;
int t1[MX], t2[MX], t3[MX];
bool vis[MX];
int read()
{
    int r=0, f=1; char ch=getchar();
    while(ch<'0'||ch>'9') {if(ch=='-') f=-1; ch=getchar();}
    while(ch>='0'&&ch<='9') {r=r*10+ch-'0'; ch=getchar();}
    return r*f;
}
void upd(char ch, int opt)
{
    int id=0;
    if(ch>='a'&&ch<='z') id=ch-'a';
    else if(ch>='A'&&ch<='Z') id=ch-'A'+26;
    if(opt==1) t1[id]++;
    if(opt==2) t2[id]++;
    if(opt==3) t3[id]++;
}
int main()
{
    // freopen("testdata.in","r",stdin);
    T=read();
    while(T--)
    {
        N=read();
        char ch[52];
        memset(vis,0,sizeof(vis));
        memset(t1,0,sizeof(t1));
        memset(t2,0,sizeof(t2));
        memset(t3,0,sizeof(t3));
        for(int i=1;i<=N*N;i++)
        {
            string s; cin >> s;
            // cout << s << '\n';
            if(s.size()==2) 
            {
                if(s[0]==s[1]) upd(s[0],3);
                else upd(s[0],1), upd(s[1],2);
            }
            else upd(s[0],2);
        }
        for(int num=0;num<N;num++)
        {
            int n1=0, n2=0, n3=0;
            for(int i=0;i<N;i++)
            {
                for(int j=0;j<N;j++)
                {
                    int now=i*j;
                    if(now>=N) 
                    {
                        if(now%N==num&&now/N==num) n3++;
                        else if(now%N==num) n2++;
                        else if(now/N==num) n1++;
                    }
                    else if(now==num) n2++;
                }
            }
            // cout << "num=" << num << ", n=" << n1 << " " << n2 << " " << n3 << '\n';
            for(int i=0;i<N;i++)
            {
                if(t1[i]==n1&&t2[i]==n2&&t3[i]==n3&&!vis[i]) 
                {
                    // cout << "I=" << i << ", num=" << num << '\n';
                    vis[i]=1; ch[num]=(i<=25)?'a'+i:'A'+i-26;
                }
            }
        }
        for(int i=0;i<N;i++) cout << ch[i]; cout << '\n';
    }
    return (0-0);
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 3788kb

input:

2
3
a b a b b b b c cc
4
d d d d d c b a d b cd cb d a cb bc

output:

bca
dcba

result:

ok OK

Test #2:

score: 0
Accepted
time: 1ms
memory: 3528kb

input:

2
4
d a a bc ba bc b a a a d a a cb c c
4
a b da b b d ad b db b a c da b c b

output:

abcd
bdac

result:

ok OK

Test #3:

score: -100
Wrong Answer
time: 5ms
memory: 3528kb

input:

50
3
b b b a a c b b cc
4
d ab c ad d b ba ab c b d d d d d a
5
a aa aa ab ab ae b b e c c c ba c c c c dd d d dd c e c e
6
a ca a a a a a a ce a a b ba ba bc bc bd be e c c ca a cd cd be d d dc dc e e a eb f f
7
a a a a a a a a cf a a a a b b b b c c c cf a dd d dc d dd e f ed ee ee fb eg eg eg eg ...

output:

bca
dabc
cadbe
abcdef
aefdcgb
fcheabgd
bhgfedcia
jhcgfideba
fjbadkegcih
klhgjbaedcif
igkjmclfedhba
nflijahgmbdcek
anmlfijbgkhdceo
nofmlkjchdbegipa
aponblgjihcfqdkme
iqmonhckfrpgjedlba
prisodmbkjqghfencla
tcrdpoaklmjihfgeqsbn
utiraponmlksghjfecdbq
qotsrvjunmlkpiegfhdcba
pvutsrhwoimlnjeqgfedbca
xbvuts...

result:

wrong answer invalid character e at case #21