QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#783079 | #9799. Magical Palette | caojc# | WA | 37ms | 3864kb | C++20 | 4.8kb | 2024-11-25 23:12:59 | 2024-11-25 23:13:00 |
Judging History
answer
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;
#define pb push_back
#define ls (u << 1)
#define rs (u << 1 | 1)
typedef long long LL;
typedef pair<int, int> PII;
// #define debug(args...) {}
#define debug(args...) { \
string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); \
stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); cout << '\n';}
void err(istream_iterator<string> it){}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
cout << *it << " = " << a << ' ';
err(++it, args...);
}
int cal(int n, int m) {
vector<vector<int>> a, b;
int tot = n * m;
vector<int> st(tot);
vector<int> now;
auto dfs = [&](auto self, int n, int k, vector<vector<int>> &buk)->void {
if (k == n) {
buk.pb(now);
return ;
}
for (int i = 0; i < tot; i++) {
if (st[i]) continue;
st[i] = true;
now.pb(i);
self(self, n, k + 1, buk);
now.pop_back();
st[i] = false;
}
};
dfs(dfs, n, 0, a);
dfs(dfs, m, 0, b);
for (auto c : a) {
for (auto d : b) {
int ok = 1;
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
int x = c[i] * d[j] % (n * m);
if (st[x]) {
ok = false;
break;
}
st[x] = true;
}
}
if (ok) {
cerr << "--------------------------------\n";
cerr << n << ' ' << m << "\n";
for (int i = 0; i < n; i++) cerr << c[i] << " \n"[i + 1 == n];
for (int i = 0; i < m; i++) cerr << d[i] << " \n"[i + 1 == m];
cerr << "--------------------------------\n";
return 1;
}
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
int x = c[i] * d[j] % (n * m);
st[x] = false;
}
}
}
}
return 0;
}
void sol(int n, int m) {
int tot = n * m;
vector<int> st(tot), num(tot);
vector<int> a(1, 1), b(1, 1);
num[1] = true;
int ac = 0;
auto dfs2 = [&](auto self, int k, int lst)->void {
if (k == m) {
ac = 1;
cout << n << ' ' << m << "\n";
for (int i = 0; i < n; i++) cout << a[i] << " \n"[i + 1 == n];
for (int i = 0; i < m; i++) cout << b[i] << " \n"[i + 1 == m];
return ;
}
for (int i = lst + 1; i < tot; i++) {
if (st[i]) continue;
int ok = true;
unordered_set<int> fuck;
for (int j = 0; j < n; j++) {
int x = a[j] * i % tot;
if (num[x] || fuck.count(x)) {
ok = false;
break;
}
fuck.insert(x);
}
if (!ok) continue;
for (int j = 0; j < n; j++) {
int x = a[j] * i % tot;
num[x] = true;
}
st[i] = true;
b.pb(i);
self(self, k + 1, i);
b.pop_back();
st[i] = false;
for (int j = 0; j < n; j++) {
int x = a[j] * i % tot;
num[x] = false;
}
if (ac) return ;
}
};
auto dfs1 = [&](auto self, int k, int lst)->void {
if (k == n) {
dfs2(dfs2, 1, 1);
return ;
}
for (int i = lst + 1; i < tot; i++) {
if (st[i]) continue;
st[i] = num[i] = true;
a.pb(i);
self(self, k + 1, i);
a.pop_back();
st[i] = num[i] = false;
if (ac) return ;
}
};
dfs1(dfs1, 1, 1);
}
void real(int n, int m) {
if (gcd(n, m) != 1) {
cout << "No\n";
return ;
}
cout << "Yes\n";
for (int i = 0; i < n; i++) cout << i * m + 1 << " \n"[i + 1 == n];
for (int i = 0; i < m; i++) cout << i * n + 1 << " \n"[i + 1 == m];
}
void solve() {
int n, m;
cin >> n >> m;
real(n, m);
// for (int i = 4; i <= 10; i++) real(3, i);
// for (int n = 1; n <= 5; n++) {
// for (int m = 1; m <= 5; m++) {
// if (n > m) cout << "_";
// else cout << cal(n, m);
// }
// cout << "\n";
// }
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int tt = 1; cin >> tt;
while (tt--) solve();
return 0;
}
/*
g++ b.cpp -Wall --extra -o b && ./b < in.txt > out.txt
*/
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3624kb
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: 37ms
memory: 3864kb
input:
1 1 1000000
output:
Yes 1 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:
wrong answer Integer parameter [name=b[1000000]] equals to 1000000, violates the range [0, 999999] (test case 1)