QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#799500 | #9799. Magical Palette | xh_team# | WA | 10ms | 11512kb | C++20 | 1.5kb | 2024-12-05 15:02:08 | 2024-12-05 15:02:09 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define PII pair<int,int>
#define lson 2*p
#define rson 2*p+1
#define x first
#define y second
const int N=1e6+10;
const int mod=1e9+7;
int n,m;
vector<int> a,b;
int vis[N];
void solve() {
cin>>n>>m;
int flag=0;
if(n>m) swap(n,m),flag=1;
if(n==2&&m==2) {
cout<<"No"<<endl;
return ;
}
if(!(n%2==0&&!vis[m])) {
cout<<"No"<<endl;
return ;
}
a.clear(),b.clear();
cout<<"Yes"<<endl;
if(flag) {
for(int i=1;i<=m;i++) cout<<(i-1)*n+1<<" ",a.push_back((i-1)*n+1);
cout<<endl;
for(int i=1;i<=n;i++) cout<<i<<" ",b.push_back(i);
} else {
for(int i=1;i<=n;i++) cout<<i<<" ",a.push_back(i);
cout<<endl;
for(int i=1;i<=m;i++) cout<<(i-1)*n+1<<" ",b.push_back((i-1)*n+1);
}
cout<<endl;
// flag=1;
// set<int> st;
// for(int x:a) {
// for(int y:b) {
// int z=x*y%(n*m);
// if(st.count(z)) {
// flag=0;
// }
// st.insert(z);
// }
// }
// cout<<st.size()<<endl;
// if(st.size()==n*m) {
// for(int x:a) cout<<x<<" ";
// cout<<endl;
// for(int x:b) cout<<x<<" ";
// cout<<endl;
//// exit(0);
// }
// cout<<endl;
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int T=1;
for(int i=2;i<N;i++) {
if(!vis[i]) {
for(int j=i*2;j<N;j+=i) vis[j]=1;
}
}
cin>>T;
while(T--) {
solve();
}
}
详细
Test #1:
score: 100
Accepted
time: 10ms
memory: 11420kb
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: 6ms
memory: 11512kb
input:
1 1 1000000
output:
No
result:
wrong answer Wrong Verdict (test case 1)