QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#781812 | #9799. Magical Palette | comp_towels_cat# | WA | 38ms | 11372kb | C++17 | 2.4kb | 2024-11-25 17:36:09 | 2024-11-25 17:36:11 |
Judging History
answer
#include <bits/stdc++.h>
#define int long long
#define fadd(a,b,c) for (int a=b;a<=c;a++)
#define fsub(a,b,c) for (int a=b;a>=c;a--)
#define ReadMany(arr,var,l,r) for (int var=l;var<=r;var++) cin >> arr[var];
#define PrintMany(arr,var,l,r) for (int var=l;var<=r;var++) cout << arr[var] << " \n"[var==r];
#define F first
#define S second
#define CYes cout << "Yes\n"
#define CNo cout << "No\n"
#define CYES cout << "YES\n"
#define CNO cout << "NO\n"
#define println(a) cout << (a) << '\n'
using namespace std;
typedef long long LL;
typedef pair<int,int> PII;
void fastIO(){ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);}
class bhscer {
public:
template<typename FIRST, typename ...PACK> static void debug(FIRST first, PACK... params) { std::cout<< first <<' '; debug(params...);}
template<typename T> static void debug(T end) { std::cout << end << std::endl; }
};
const int N = 5e5;
int a[N], b[N];
bool ok = false;
int n,m;
void check() {
if (ok == false) {
cout << "pass on " << n << " ," << m << endl;
return;
}
set<int> s;
for (int i=1;i<=n;i++) {
for (int j=1;j<=m;j++) {
s.insert(a[i] * b[j] % (n*m));
}
}
if (s.size() == n*m) {
cout << "pass on" << n << " ," << m << endl;
} else {
cout << "failed on " << n << " ," << m << endl;
assert(false);
}
}
void solve() {
bool reverse = false;
if (n > m) {
reverse = true;
swap(n,m);
}
if (__gcd(n,m) > 1) {
ok = false;
} else {
ok = true;
}
int sum = 1;
for (int i=1;i<=n;i++) {
reverse ? b[i] = sum: a[i] = sum;
sum += m;
}
sum = 1;
for (int i=1;i<=m;i++) {
reverse ? a[i] = sum : b[i] = sum;
sum += n;
}
if (reverse) {
swap(n,m);
}
// check();
if (!ok) {
CNo;
} else {
CYes;
for (int i=1;i<=n;i++) {
cout << a[i] << " \n"[i==n];
}
for (int i=1;i<=m;i++) {
cout << b[i] << " \n"[i==m];
}
}
}
signed main() {
fastIO();
// for (n=1;n<50;n++)
// for (m=1;m<50;m++)
int T = 1; cin >> T;
while (T--) {
cin >> n >> m;
solve();
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 5676kb
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
Wrong Answer
time: 38ms
memory: 11372kb
input:
1 1 1000000
output:
Yes 500001 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 1...
result:
wrong answer Integer parameter [name=b[1000000]] equals to 1000000, violates the range [0, 999999] (test case 1)