QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#781736#9799. Magical PalettexxWA 61ms20724kbC++205.1kb2024-11-25 17:19:022024-11-25 17:19:03

Judging History

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

  • [2024-11-25 17:19:03]
  • 评测
  • 测评结果:WA
  • 用时:61ms
  • 内存:20724kb
  • [2024-11-25 17:19:02]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
#define ll long long
#define yes cout<<"Yes\n";
#define no cout<<"No\n";
#define ok cout<<"OK\n";
#define pii pair<int,int>
#define pis pair<int,string>
#define endl "\n"
typedef long long LL;
using namespace std;
// const int N=5e5+10;
// int mod=1e9+7;
// int p[N];
// int a[N];
// struct node {
//     int l,r,mn,mx,res;
// }tr[N*4];
// int find(int x) {
//     if(x==p[x])return  x;
//     return p[x]=find(p[x]);
// }
// void js(int p,int l,int r) {
//     tr[p]={l,r};
//     if(l==r) {
//         tr[p].mn=tr[p].res=tr[p].mx=a[l];
//         return;
//     }
//     int mid=(l+r)/2;
//     js(p,l,mid);
//     js(p,mid+1,r);
//     tr[p].mn=min(tr[p*2].mn,tr[p*2+1].mn);
//     tr[p].mx=max(tr[p*2].mx,tr[p*2+1].mx);
// }
// int findmn(int p,int l,int r,int pl,int pr) {
//     if(pl<=r&&r<=pr) {
//             return tr[p].mn;
//     }
//     int mid=(l+r)/2;
//     if(pr<=mid)return  findmn(p,l,mid,pl,pr);
//     else if(pl>mid)return findmn(p,mid+1,r,pl,pr);
//     else return min(findmn(p,l,mid,pl,pr),findmn(p,mid+1,r,pl,pr) );
// }
//
// int findmx(int p,int l,int r,int pl,int pr) {
//     if(pl<=r&&r<=pr) {
//         return tr[p].mx;
//     }
//     int mid=(l+r)/2;
//     if(pr<=mid)return  findmx(p,l,mid,pl,pr);
//     else if(pl>mid)return findmx(p,mid+1,r,pl,pr);
//     else return max(findmx(p,l,mid,pl,pr),findmx(p,mid+1,r,pl,pr) );
// }
//5 7 3 6

// int dfn[N],low[N];
// using ull = unsigned long long;
// const ull P = 133331;
//
// struct Hash {
//     const int n;
//     std::vector<ull> p, h1, h2;
//     std::string s;
//     Hash(std::string s_) : s(s_), n(s_.size() - 1), h1(n + 2), h2(n + 2), p(n + 2) { // idx by 1
//         p[0] = 1; h1[0] = 0, h2[0] = 0;
//         for(int i = 1 ; i <= n ; i ++) p[i] = p[i - 1] * P;
//         for(int i = 1 ; i <= n ; i ++) h1[i] = h1[i - 1] * P + s_[i];
//         for(int i = n ; i >= 1 ; i --) h2[i] = h2[i + 1] * P + s_[i];
//     }
//
//     ull get(int l, int r) { // s[l] s[l + 1] ... s[r]
//         return h1[r] - h1[l - 1] * p[r - l + 1];
//     }
//
//     ull get_unnomal(int l, int r, int L, int R) { // s[l] s[l + 1] ... s[r] s[L] s[L + 1]...s[R]
//         return get(l, r) * p[R - L + 1] + get(L, R);
//     }
//
//     ull get_rev(int l, int r) { // s[r] s[r - 1] ... s[l]
//         return h2[l] - h2[r + 1] * p[r - l + 1];
//     }
//
//     ull modify(std::string &s, int idx, char c) { // 修改 idx 位为 x的hash值
//         return h1[n] + p[n - idx] * (c - s[idx]);
//     }
// };
const int N=1e6+10;
map<int,int> mp;
int st[N];
void init(){
    for(int i=2;i<=1e6;i++){
        if(st[i]==0){
            for(int j=i+i;j<=1e6;j+=i){
                if(j==499999){
                    //cout<<i<<" "<<j<<endl;
                }
                st[j]++;
            }
        }
    }
}
/*

1
1 10000
*/
int a[N],b[N];
void solve() {

    int n,m;
    cin>>n>>m;
    //cout<<st[n]<<" "<<st[m]<<endl;
    
    if(n==1){
        cout<<"Yes\n";
        for(int i=1;i<=n;i++){
            a[i]=i;
            cout<<a[i]<<" ";
        }cout<<endl;
        b[1]=1;

        for(int i=2;i<=m;i++){
            b[i]=b[i-1]+n;

        }
        for(int i=1;i<=m;i++){
            cout<<b[i]-1<<" ";
        }cout<<endl;

    }
    else if(m==1){
            cout<<"Yes\n";
            for(int i=1;i<=m;i++){
                b[i]=i;
            }
            a[1]=1;
            //cout<<endl;
            for(int i=2;i<=n;i++){
                a[i]=a[i-1]+m;

            }
            //cout<<endl;
            for(int i=1;i<=n;i++){
                cout<<a[i]-1<<" ";
            }
            cout<<endl;
            for(int i=1;i<=m;i++){
                cout<<b[i]<<" ";
            }
            cout<<endl;
    }
    else if((st[n]<=2&&st[m]<=2&&n!=m)||(n!=m&&(n==2||m==2))){
        if(n<m){
            cout<<"Yes\n";
            for(int i=1;i<=n;i++){
                a[i]=i;
                cout<<a[i]<<" ";
            }cout<<endl;
            b[1]=1;

            for(int i=2;i<=m;i++){
                b[i]=b[i-1]+n;

            }
            for(int i=1;i<=m;i++){
                cout<<b[i]<<" ";
            }cout<<endl;

        }
        else {
                cout<<"Yes\n";
            for(int i=1;i<=m;i++){
                b[i]=i;
            }
            a[1]=1;
            //cout<<endl;
            for(int i=2;i<=n;i++){
                a[i]=a[i-1]+m;

            }
            //cout<<endl;
            for(int i=1;i<=n;i++){
                cout<<a[i]<<" ";
            }cout<<endl;

            for(int i=1;i<=m;i++){
                cout<<b[i]<<" ";
            }cout<<endl;
        }
        //
    }
    else {
        cout<<"No\n";
    }

}

signed main(){

#ifdef ACM
     freopen("input.in","r",stdin);
     freopen("output.out","w",stdout);
#endif
    // ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int T=1;
    init();
    cin>>T;
    while(T--) {
        solve();
    }
    return 0;
}
/*

*/

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 6ms
memory: 13492kb

input:

2
2 3
2 2

output:

Yes
1 2 
1 3 5 
No

result:

ok 2 cases (2 test cases)

Test #2:

score: 0
Accepted
time: 61ms
memory: 20724kb

input:

1
1 1000000

output:

Yes
1 
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100...

result:

ok 1 cases (1 test case)

Test #3:

score: 0
Accepted
time: 58ms
memory: 19992kb

input:

1
1000000 1

output:

Yes
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 10...

result:

ok 1 cases (1 test case)

Test #4:

score: -100
Wrong Answer
time: 31ms
memory: 17776kb

input:

1
2 500000

output:

Yes
1 2 
1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 51 53 55 57 59 61 63 65 67 69 71 73 75 77 79 81 83 85 87 89 91 93 95 97 99 101 103 105 107 109 111 113 115 117 119 121 123 125 127 129 131 133 135 137 139 141 143 145 147 149 151 153 155 157 159 161 163 165 167 169 171 17...

result:

wrong answer Wrong Verdict (test case 1)