QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#822976 | #9799. Magical Palette | ucup-team2179# | WA | 52ms | 27592kb | C++23 | 1.3kb | 2024-12-20 17:55:42 | 2024-12-20 17:55:46 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
#define ll long long
#define pii pair<int, int>
using namespace std;
int vis[1000000]{};
void solve() {
int n,m;
cin>>n>>m;
int flag=0;
if(n>m)swap(n,m),flag=1;
if(__gcd(n,m)!=1){
cout<<"No\n";return;
}
// int d2=n;
vector<int>now;
for(int d2=1;d2<=n;d2++)
for(int i=1;i<=m;i++){
if(__gcd(i,d2)!=1)continue;
vector<int>b;
vector<int>a;
for(int j=1;j<=m;j++)b.push_back(1+d2*(j-1));
for(int j=1;j<=n;j++)a.push_back(1+i*(j-1));
int valid=1;
for(auto p:a)
for(auto t:b){
if(valid==0)break;
if(vis[p*t%(n*m)]){
valid=0;
for(auto x:now)vis[x]=0;
now.clear();
break;
}
vis[p*t%(n*m)]=1;
now.push_back(p*t%(n*m));
}
if(valid){
if(flag)swap(a,b);
cout<<"Yes\n";
for(auto p:a)cout<<p<<" ";cout<<"\n";
for(auto p:b)cout<<p<<" ";cout<<"\n";
return ;
}
}
cout<<"No\n";
}
signed main() {
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int t = 1;
cin >> t;
while (t--) solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3588kb
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: 52ms
memory: 27592kb
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 1...
result:
wrong answer Integer parameter [name=b[1000000]] equals to 1000000, violates the range [0, 999999] (test case 1)