QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#783450 | #9799. Magical Palette | Kleaves | WA | 0ms | 3716kb | C++17 | 2.3kb | 2024-11-26 09:53:51 | 2024-11-26 09:53:52 |
Judging History
answer
#pragma GCC optimize(3)
#define _CRT_SECURE_NO_WARNINGS 1
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define testin freopen("testin1.txt", "r", stdin)
#define testout freopen("testout1.txt", "w", stdout)
#define NO cout<<"No"<<endl
#define YES cout<<"Yes"<<endl
#define MAYBE cout<<"MAYBE"<<endl
#define endl '\n'
#define ALL(x) x.begin(),x.end()
#define INS(x)inserter(x,x.begin())
using namespace std;
const ll MAXN = 1000010;
const ll INF = 0x3f3f3f3f;
const ll mod = 998244353;
bool DEBUG = false;
vector<ll>numn,numm;
ll uniq[MAXN][2];
void solve() {
ll n, m;
cin >> n >> m;
if (gcd(n, m) != 1) {
cout << "No" << endl;
return;
}
cout << "Yes" << endl;
for (int i = 0; i < n; i++) {
//cout << (1 + (n - 1) * i) % (n * m) << ' ';
}
cout << endl;
for (int i = 0; i < m; i++) {
//cout << (1 + (m - 1) * i) % (n * m) << ' ';
}
cout << endl;
ll flag = 1;
for (ll d1 = n-1; d1 >= 1; d1--) {
for (ll d2 = m-1; d2 >= 1; d2--) {
flag = 1;
numn.clear();
numm.clear();
for (ll i = 0; i < n; i++) {
numn.push_back((1 + d1 * i) % (n * m));
}
for (ll i = 0; i < m; i++) {
numm.push_back((1 + d2 * i) % (n * m));
}
//map<ll, pair<ll, ll>>uniq;
for (int i = 0; i < m * n; i++) {
uniq[i][0] = -1; uniq[i][1] = -1;
}
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
ll tmp = (numn[i] * numm[j]) % (m * n);
if (uniq[tmp][0] != -1) {
if (DEBUG) {
cout << "ERROR:" << tmp << endl;
ll fst = uniq[tmp][0];
ll snd = uniq[tmp][1];
cout << "FIRST:" << fst + 1 << "," << snd + 1 << endl;
cout << "SECOND:" << i + 1 << "," << j + 1 << endl;
}
flag = 0;
break;
}
else {
uniq[tmp][0] = i;
uniq[tmp][1] = j;
}
}
if (flag == 0)break;
}
if (flag == 1) {
for (int i = 0; i < n; i++) {
cout << (1 + d1 * i) % (n * m) << ' ';
}
cout << endl;
for (int i = 0; i < m; i++) {
cout << (1 + d2 * i) % (n * m) << ' ';
}
cout << endl;
return;
}
}
}
return;
}
int main() {
//testin;
//freopen("case1out.txt", "w", stdout);
ios::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
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: 3712kb
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: 3716kb
input:
1 1 1000000
output:
Yes
result:
wrong output format Unexpected end of file - int32 expected (test case 1)