QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#840240#9799. Magical Palettefrankly6#WA 64ms13148kbC++171.2kb2025-01-02 16:32:252025-01-02 16:32:25

Judging History

This is the latest submission verdict.

  • [2025-01-02 16:32:25]
  • Judged
  • Verdict: WA
  • Time: 64ms
  • Memory: 13148kb
  • [2025-01-02 16:32:25]
  • Submitted

answer

#include<iostream>
#include<cstdio>
#define int long long
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;
}
signed 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);
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 7724kb

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: 64ms
memory: 13148kb

input:

1
1 1000000

output:

Yes
1 
1 1000000 1999999 2999998 3999997 4999996 5999995 6999994 7999993 8999992 9999991 10999990 11999989 12999988 13999987 14999986 15999985 16999984 17999983 18999982 19999981 20999980 21999979 22999978 23999977 24999976 25999975 26999974 27999973 28999972 29999971 30999970 31999969 32999968 3399...

result:

wrong answer Integer parameter [name=b[2]] equals to 1000000, violates the range [0, 999999] (test case 1)