QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#779953 | #9799. Magical Palette | racel | WA | 1171ms | 61752kb | C++20 | 1.6kb | 2024-11-24 23:03:09 | 2024-11-24 23:03:12 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
bool validate() {
vector<int> cc = {1,
3,
5,
7,
9};
vector<int> rr = {
11,
3,
5,
7
};
int n = cc.size();
int m = rr.size();
set<int> st;
for(int i : cc) {
for(int j : rr) {
st.insert((i * j) % (n * m));
}
}
if(st.size() == n * m) {
return true;
}
return false;
}
void solve() {
int n, m;
cin >> n >> m;
if(n == m) {
cout << "No\n";
return;
}
vector<int> c(n * m), r(n * m);
for(int i = 0; i < n * m; i++) c[i] = i + 1;
for(int i = 0; i < n * m; i++) r[i] = i + 1;
int cnt = 0;
// cout << validate() << endl;
auto rng = std::default_random_engine {};
while(true) {
shuffle(c.begin(), c.end(), rng);
shuffle(r.begin(), r.end(), rng);
vector<int> cc(c.begin(), c.begin() + n);
vector<int> rr(r.begin(), r.begin() + m);
set<int> st;
for(int i : cc) {
for(int j : rr) {
st.insert((i * j) % (n * m));
}
}
if(st.size() == n * m) {
cout << "Yes\n";
for(int i : cc) cout << i << ' ';
cout << endl;
for(int i : rr) cout << i << ' ';
cout << endl;
return;
}
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
signed tc = 1;
cin >> tc;
while(tc--) solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3616kb
input:
2 2 3 2 2
output:
Yes 4 1 1 5 3 No
result:
ok 2 cases (2 test cases)
Test #2:
score: -100
Wrong Answer
time: 1171ms
memory: 61752kb
input:
1 1 1000000
output:
Yes 302455 27884 327592 328570 343798 655951 37939 759976 843132 555418 111028 482257 977642 767021 127395 135283 558920 39088 762852 12431 343599 889367 121795 89671 334924 377055 585237 807025 139147 551662 750800 398420 911186 46422 927073 224471 329866 268179 100994 536381 719437 248239 275255 ...
result:
wrong answer Integer parameter [name=b[867933]] equals to 1000000, violates the range [0, 999999] (test case 1)