QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#822969 | #9799. Magical Palette | ucup-team2179# | WA | 0ms | 3604kb | C++23 | 1.2kb | 2024-12-20 17:53:16 | 2024-12-20 17:53:16 |
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;
vector<int>b;
for(int i=1;i<=m;i++)b.push_back(1+d2*(i-1));
for(int i=1;i<m;i++){
if(__gcd(i,d2)!=1)continue;
vector<int>a;
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);
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: 0
Wrong Answer
time: 0ms
memory: 3604kb
input:
2 2 3 2 2
output:
1 2 1 3 5 No
result:
wrong answer Token parameter [name=verdict] equals to "1", doesn't correspond to pattern "Yes|No" (test case 1)