QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#786104#9799. Magical Palettecjpjh#RE 0ms3640kbC++202.8kb2024-11-26 20:19:382024-11-26 20:19:39

Judging History

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

  • [2024-11-26 20:19:39]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:3640kb
  • [2024-11-26 20:19:38]
  • 提交

answer

#include<bits/stdc++.h>

using namespace std;

#define int long long

int a[100], b[100];
// int n, m;

vector<int> num;
int mod;
int t;
vector<int> mrk(1000);
int useh[100], usel[100];

bool check(int n, int m) {
    mod = n * m;
    mrk.assign(n * m, 0);
    for(int i = 1; i <= n; ++i) {
        for(int j = 1; j <= m; ++j) {
            t = a[i] * b[j] % mod;
            if(mrk[t]) return 0;
            mrk[t] = 1;
        }
    }
    return 1;
}

// void print() {
//     for(int i = 1; i <= n; ++i) {
//         cout << a[i] << " ";
//     }
//     cout << endl;
//     for(int i = 1; i <= m; ++i) {
//         cout << b[i] << " ";
//     }
//     cout << "\n\n";
// }
//
// void dfs(int p) {
//     if(p == mod) {
//         for(int i = 0; i < n; ++i) {
//             a[i + 1] = num[i];
//         }
//         for(int i = n; i < n + m; ++i) {
//             b[i - n + 1] = num[i];
//         }
//         if(check()) {
//             print();
//         }
//         return;
//     }
//     for(int i = 1; i < mod; ++i) {
//         if(p < n) {
//             if(useh[i]) continue;
//             useh[i] = 1;
//             num.push_back(i);
//             dfs(p + 1);
//             num.pop_back();
//             useh[i] = 0;
//         } else {
//             if(usel[i]) continue;
//             usel[i] = 1;
//             num.push_back(i);
//             dfs(p + 1);
//             num.pop_back();
//             usel[i] = 0;
//         }
//     }
// }

bool way1(int n, int m) {
    mod = n * m;
    for(int i = 1; i <= n; ++i) {
        a[i] = i;
    }
    for(int i = 1; i <= m; ++i) {
        b[i] = 1 + (i - 1) * n;
    }
    return check(n, m);
}

bool way2(int n, int m) {
    mod = n * m;
    for(int i = 1; i <= n; ++i) {
        a[i] = 1 + (i - 1) * m;
    }
    for(int i = 1; i <= m; ++i) {
        b[i] = 1 + (i - 1) * n;
    }
    return check(n, m);
}

void solve() {
    int n, m;
    cin >> n >> m;

    if(__gcd(n, m) != 1) {
        cout << "No\n";
    } else {
        cout << "Yes\n";
        for(int i = 1; i <= n; ++i) {
            a[i] = 1 + (i - 1) * m;
            cout << a[i] << " ";
        }
        cout << "\n";
        for(int i = 1; i <= m; ++i) {
            b[i] = 1 + (i - 1) * n;
            cout << b[i] << " ";
        }
        cout << "\n";
        // for(int i = 1; i <= n; ++i) {
        //     cout << a[i] << " ";
        // }
        // cout << "\n";

    }
    // for(int i = 1; i <= 10; ++i) {
    //     for(int j = 1; j <= 10; ++j) {
    //         cout << i << " " << j << " " << way1(i, j) << " " << way2(i, j) << endl;
    //     }
    // }

}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int T = 1;
    cin >> T;
    while (T--) {
        solve();
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

2
2 3
2 2

output:

Yes
1 4 
1 3 5 
No

result:

ok 2 cases (2 test cases)

Test #2:

score: -100
Runtime Error

input:

1
1 1000000

output:


result: