QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#781857 | #9799. Magical Palette | xx | WA | 326ms | 81668kb | C++20 | 5.6kb | 2024-11-25 17:44:45 | 2024-11-25 17:44:46 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
#define ll long long
#define yes cout<<"Yes\n";
#define no cout<<"No\n";
#define ok cout<<"OK\n";
#define pii pair<int,int>
#define pis pair<int,string>
#define endl "\n"
typedef long long LL;
using namespace std;
// const int N=5e5+10;
// int mod=1e9+7;
// int p[N];
// int a[N];
// struct node {
// int l,r,mn,mx,res;
// }tr[N*4];
// int find(int x) {
// if(x==p[x])return x;
// return p[x]=find(p[x]);
// }
// void js(int p,int l,int r) {
// tr[p]={l,r};
// if(l==r) {
// tr[p].mn=tr[p].res=tr[p].mx=a[l];
// return;
// }
// int mid=(l+r)/2;
// js(p,l,mid);
// js(p,mid+1,r);
// tr[p].mn=min(tr[p*2].mn,tr[p*2+1].mn);
// tr[p].mx=max(tr[p*2].mx,tr[p*2+1].mx);
// }
// int findmn(int p,int l,int r,int pl,int pr) {
// if(pl<=r&&r<=pr) {
// return tr[p].mn;
// }
// int mid=(l+r)/2;
// if(pr<=mid)return findmn(p,l,mid,pl,pr);
// else if(pl>mid)return findmn(p,mid+1,r,pl,pr);
// else return min(findmn(p,l,mid,pl,pr),findmn(p,mid+1,r,pl,pr) );
// }
//
// int findmx(int p,int l,int r,int pl,int pr) {
// if(pl<=r&&r<=pr) {
// return tr[p].mx;
// }
// int mid=(l+r)/2;
// if(pr<=mid)return findmx(p,l,mid,pl,pr);
// else if(pl>mid)return findmx(p,mid+1,r,pl,pr);
// else return max(findmx(p,l,mid,pl,pr),findmx(p,mid+1,r,pl,pr) );
// }
//5 7 3 6
// int dfn[N],low[N];
// using ull = unsigned long long;
// const ull P = 133331;
//
// struct Hash {
// const int n;
// std::vector<ull> p, h1, h2;
// std::string s;
// Hash(std::string s_) : s(s_), n(s_.size() - 1), h1(n + 2), h2(n + 2), p(n + 2) { // idx by 1
// p[0] = 1; h1[0] = 0, h2[0] = 0;
// for(int i = 1 ; i <= n ; i ++) p[i] = p[i - 1] * P;
// for(int i = 1 ; i <= n ; i ++) h1[i] = h1[i - 1] * P + s_[i];
// for(int i = n ; i >= 1 ; i --) h2[i] = h2[i + 1] * P + s_[i];
// }
//
// ull get(int l, int r) { // s[l] s[l + 1] ... s[r]
// return h1[r] - h1[l - 1] * p[r - l + 1];
// }
//
// ull get_unnomal(int l, int r, int L, int R) { // s[l] s[l + 1] ... s[r] s[L] s[L + 1]...s[R]
// return get(l, r) * p[R - L + 1] + get(L, R);
// }
//
// ull get_rev(int l, int r) { // s[r] s[r - 1] ... s[l]
// return h2[l] - h2[r + 1] * p[r - l + 1];
// }
//
// ull modify(std::string &s, int idx, char c) { // 修改 idx 位为 x的hash值
// return h1[n] + p[n - idx] * (c - s[idx]);
// }
// };
const int N=1e6+10;
map<int,int> mp;
int st[N];
void init(){
for(int i=2;i<=1e6;i++){
if(st[i]==0){
for(int j=i+i;j<=1e6;j+=i){
if(j==499999){
//cout<<i<<" "<<j<<endl;
}
st[j]++;
}
}
}
}
/*
1
1 10000
*/
int a[N],b[N];
void solve() {
int n,m;
cin>>n>>m;
if(n==1){
cout<<"Yes\n";
for(int i=1;i<=n;i++){
a[i]=i;
cout<<a[i]<<" ";
}cout<<endl;
b[1]=1;
for(int i=2;i<=m;i++){
b[i]=b[i-1]+n;
}
for(int i=1;i<=m;i++){
cout<<b[i]-1<<" ";
}cout<<endl;
return;
}
else if(m==1){
cout<<"Yes\n";
for(int i=1;i<=m;i++){
b[i]=i;
}
a[1]=1;
//cout<<endl;
for(int i=2;i<=n;i++){
a[i]=a[i-1]+m;
}
//cout<<endl;
for(int i=1;i<=n;i++){
cout<<a[i]-1<<" ";
}
cout<<endl;
for(int i=1;i<=m;i++){
cout<<b[i]<<" ";
}
cout<<endl;
return;
}
else if(n<m){
//cout<<"Yes\n";
for(int i=1;i<=n;i++){
a[i]=i;
//cout<<a[i]<<" ";
}//cout<<endl;
b[1]=1;
for(int i=2;i<=m;i++){
b[i]=b[i-1]+n;
}
//for(int i=1;i<=m;i++){
//cout<<b[i]<<" ";
//}//cout<<endl;
}
else if(n>m){
//cout<<"Yes\n";
for(int i=1;i<=m;i++){
b[i]=i;
}
a[1]=1;
//cout<<endl;
for(int i=2;i<=n;i++){
a[i]=a[i-1]+m;
}
//cout<<endl;
//for(int i=1;i<=n;i++){
//cout<<a[i]<<" ";
//}//cout<<endl;
//for(int i=1;i<=m;i++){
//cout<<b[i]<<" ";
//}//cout<<endl;
}
else {
cout<<"No\n";
return;
}
map<int,int> mp;
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++){
mp[a[i]*b[j]%(n*m) ]++;
if(mp[a[i]*b[j]%(n*m)]>1){
//cout<<mp[a[i]*b[j]%(n*m)]<<" "<<a[i]*b[j]%(n*m)<<endl;
cout<<"No\n";
return;
}
}
cout<<"Yes\n";
for(int i=1;i<=n;i++){
cout<<a[i]<<" ";
}
cout<<endl;
for(int i=1;i<=m;i++){
cout<<b[i]<<" ";
}
cout<<endl;
}
signed main(){
#ifdef ACM
freopen("input.in","r",stdin);
freopen("output.out","w",stdout);
#endif
// ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int T=1;
init();
cin>>T;
while(T--) {
solve();
}
return 0;
}
/*
*/
詳細信息
Test #1:
score: 100
Accepted
time: 6ms
memory: 13468kb
input:
2 2 3 2 2
output:
Yes 1 2 1 3 5 No
result:
ok 2 cases (2 test cases)
Test #2:
score: 0
Accepted
time: 58ms
memory: 20072kb
input:
1 1 1000000
output:
Yes 1 0 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...
result:
ok 1 cases (1 test case)
Test #3:
score: 0
Accepted
time: 55ms
memory: 19720kb
input:
1 1000000 1
output:
Yes 0 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:
ok 1 cases (1 test case)
Test #4:
score: 0
Accepted
time: 227ms
memory: 64464kb
input:
1 2 500000
output:
No
result:
ok 1 cases (1 test case)
Test #5:
score: 0
Accepted
time: 319ms
memory: 81668kb
input:
1 2 499999
output:
Yes 1 2 1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 51 53 55 57 59 61 63 65 67 69 71 73 75 77 79 81 83 85 87 89 91 93 95 97 99 101 103 105 107 109 111 113 115 117 119 121 123 125 127 129 131 133 135 137 139 141 143 145 147 149 151 153 155 157 159 161 163 165 167 169 171 17...
result:
ok 1 cases (1 test case)
Test #6:
score: 0
Accepted
time: 155ms
memory: 48784kb
input:
1 500000 2
output:
No
result:
ok 1 cases (1 test case)
Test #7:
score: 0
Accepted
time: 326ms
memory: 80060kb
input:
1 499999 2
output:
Yes 1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 51 53 55 57 59 61 63 65 67 69 71 73 75 77 79 81 83 85 87 89 91 93 95 97 99 101 103 105 107 109 111 113 115 117 119 121 123 125 127 129 131 133 135 137 139 141 143 145 147 149 151 153 155 157 159 161 163 165 167 169 171 173 175...
result:
ok 1 cases (1 test case)
Test #8:
score: 0
Accepted
time: 195ms
memory: 65160kb
input:
1 3 333333
output:
No
result:
ok 1 cases (1 test case)
Test #9:
score: -100
Wrong Answer
time: 152ms
memory: 48580kb
input:
1 3 333332
output:
No
result:
wrong answer Wrong Verdict (test case 1)