QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#840065#9799. Magical Palettefrankly6#WA 1ms8636kbC++171.2kb2025-01-02 15:14:012025-01-02 15:14:02

Judging History

This is the latest submission verdict.

  • [2025-01-02 15:14:02]
  • Judged
  • Verdict: WA
  • Time: 1ms
  • Memory: 8636kb
  • [2025-01-02 15:14:01]
  • Submitted

answer

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

int T, N, M;
int ar[MX], br[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;
}
int main()
{
    // freopen("testdata.in","r",stdin);
    T=read();
    while(T--)
    {
        N=read(); M=read();
        for(int i=1;i<=N;i++) ar[i]=1+(i-1)*(N-1);
        for(int i=1;i<=M;i++) br[i]=1+(i-1)*(M-1);
        bool tag=0;
        int p=N*M;
        for(int i=1;i<=N;i++)
        {
            for(int j=1;j<=M;j++)
            {
                int now = (ar[i]*br[j]%p+p)%p;
                if(vis[now]) {tag=1; break;}
                vis[now]=1;
            }
            if(tag) break;
        }
        if(tag) cout << "No\n";
        else 
        {
            cout << "Yes\n";
            for(int i=1;i<=N;i++) cout << ar[i] << " "; cout << '\n';
            for(int i=1;i<=M;i++) cout << br[i] << " "; cout << '\n';
        }
        for(int i=0;i<=N*M;i++) vis[i]=0;
    }

    return (0-0);
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

2
2 3
2 2

output:

Yes
1 2 
1 3 5 
No

result:

ok 2 cases (2 test cases)

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 8636kb

input:

1
1 1000000

output:

No

result:

wrong answer Wrong Verdict (test case 1)